新建一個工作薄,將所有EXCEL表的檔名填到A列中,複製下面VBA程式碼到工作薄中,儲存為excel.xls後執行
Sub xlscopy()
Application.ScreenUpdating = False
"Arr陣列由所有EXCEL檔名組成
arr = [A1:A10]
For i = 1 To UBound(arr)
Workbooks.Open "資料夾路徑\" & arr(i, 1)
Workbooks(arr(i)(1)).Activate
For j = 1 To ActiveWorkbook.Sheets.Count
Sheets(j).Copy After:=Workbooks("excel.xls").Sheets(Workbooks("excel.xls").Sheets.Count)
Next
Workbooks(arr(i, 1)).Close False
Next
End Sub
新建一個工作薄,將所有EXCEL表的檔名填到A列中,複製下面VBA程式碼到工作薄中,儲存為excel.xls後執行 Sub xlscopy() Application.ScreenUpdating = False "Arr陣列由所有EXCEL檔名組成 arr = [A1:A10] For i = 1 To UBound(arr) Workbooks.Open "資料夾路徑\" & arr(i, 1) Workbooks(arr(i)(1)).Activate For j = 1 To ActiveWorkbook.Sheets.Count Sheets(j).Copy After:=Workbooks("excel.xls").Sheets(Workbooks("excel.xls").Sheets.Count) Next Workbooks(arr(i, 1)).Close False Next End Sub