For Each a In Range([A2], Cells(Rows.Count, 1).End(xlUp))
With Workbooks.Open(a)
.Sheets.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
.Close 0
End With
Next
Sheets("工作表1").Activate
載入檔案清單前, 應將A欄清空
Sub DATA_INPUT()
Sheets("工作表1").Activate
Range([A2], Cells(Rows.Count, 1).End(xlUp)(2)).ClearContents
續~原程式碼~~
End Sub
=========================
開啟檔案前, 先用DIR檢查是否存在~~
If Dir(A) <> "" Then
With Workbooks.Open(A)
.Sheets.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
.Close 0
End With
End If