- 帖子
- 552
- 主題
- 3
- 精華
- 0
- 積分
- 578
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- office 2010
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2015-2-8
- 最後登錄
- 2024-7-9
  
|
9#
發表於 2015-11-6 13:51
| 只看該作者
回復 8# mark761222
試試看- Private Sub Workbook_Open()
- Dim xlPath As Variant, Ro As Integer
- Dim xlFilea, xlFileb, arra, arrb
- xlPath = ThisWorkbook.Path & "\"
- xlFilea = ("B.xlsx")
- xlFileb = ("C.xlsx")
- arra = Sheets("工作表1").Range("A1:E1")
- arrb = Sheets("工作表1").Range("A2:E2")
- Workbooks.Open (xlPath & xlFilea)
- With Workbooks(xlFilea).Worksheets("工作表1")
- Set da = .Columns(1).Find(arra(1, 1), , , , , 2)
- If Not da Is Nothing Then GoTo 10
- Ro = .Cells(65535, 1).End(xlUp).Row + 1
-
- .Cells(Ro, 1) = arra
- End With
- 10:
- Workbooks(xlFilea).Close True
- Workbooks.Open (xlPath & xlFileb)
- With Workbooks(xlFileb).Worksheets("工作表1")
- Set da = .Columns(1).Find(arra(1, 1), , , , , 2)
- If Not da Is Nothing Then GoTo 10
- Ro = .Cells(65535, 1).End(xlUp).Row + 1
- .Cells(Ro, 1) = arrb
- End With
- 20:
- Workbooks(xlFileb).Close True
- End Sub
複製代碼 |
|