Public Sub ex()
Dim xlPath As Variant, Ro As Integer
Dim xlFile, arr
xlFile = Array("B.xlsx", "C.xlsx")
arr = Sheets("工作表1").Range("A1:E" & Sheets("工作表1").Cells(65535, 1).End(xlUp).Row)
For i = 0 To UBound(xlFile)
Workbooks.Open (xlPath & xlFile(i))
With Workbooks(xlFile(i)).Worksheets("工作表1")
Ro = .Cells(65535, 1).End(xlUp).Row
.Cells(Ro, 1).Resize(UBound(arr), UBound(arr, 2)) = arr
End With
Workbooks(xlFile(i)).Close True
Next
End Sub
文章標籤
全站熱搜

Private Sub Workbook_Open() Dim xlPath As Variant, Ro As Integer Dim xlFile, arr xlPath = ThisWorkbook.Path & "\" xlFile = Array("B.xlsx", "C.xlsx") arr = Sheets("工作表1").Range("A1:E" & Sheets("工作表1").Cells(65535, 1).End(xlUp).Row + 1) For i = 0 To UBound(xlFile) Workbooks.Open (xlPath & xlFile(i)) With Workbooks(xlFile(i)).Worksheets("工作表1") Ro = .Cells(65535, 1).End(xlUp).Row + 1 .Cells(Ro, 1).Resize(UBound(arr), UBound(arr, 2)) = arr End With Workbooks(xlFile(i)).Close True Next End Sub xlPath = ThisWorkbook.Path & "\" 宣告少了這行 .Row + 1 最後一筆+1 不然會覆蓋到資料 謝謝minyeh187 你的教學
過中看國時力了後去也特在到還上每工到隻地這定後而家 85國§語言○翻譯~公○司◎ 鉦昱﹍數﹉位翻☉譯☉公□司 提﹎供瓦紹♀文☆翻譯﹉等﹌服務◎ 電◎話~: 02-7726-◇0932 LINE-ID: 0989298406 翻§譯♂社﹂|ksuseo.tw66.com.tw/