請測試看看,謝謝
Sub test()
Dim Arr, a, fs, fc, f, f1, n&
Application.ScreenUpdating = False: Application.DisplayAlerts = False: Application.AskToUpdateLinks = False
Set fs = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = "D:\"
.Title = "選擇檔案來源資料夾"
.Show
On Error GoTo EndSub:
a = .SelectedItems(1)
End With
Tm = Timer
Set f = fs.GetFolder(a)
Set fc = f.Files
For Each f1 In fc
Set WB = Workbooks.Open(f1)
With Sheets(1)
If .FilterMode Then .ShowAllData
Arr = .Range("a1").CurrentRegion
End With
WB.Close
If [a1] = "" Then n = 1 Else n = [A65536].End(xlUp).Row + 1
Range("a" & n).Resize(UBound(Arr), UBound(Arr, 2)) = Arr
Next
Application.ScreenUpdating = True: Application.DisplayAlerts = True: Application.AskToUpdateLinks = True
MsgBox "執行完成" & Timer - Tm & " 秒"
EndSub:
End Sub作者: rouber590324 時間: 2022-8-24 14:05