我编写了这段代码,将所有文件从一个文件夹导入到我的活动工作簿中。我99%的人肯定它可以在Windows上运行,但是我认为Mac的文件路径以及与之交互的方式需要更改。
Sub ConslidateWorkbooks()
Dim FolderPath As String
Dim Filename As String
Dim sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = "/Users/charliekeegan/Desktop/Tester1/"
Filename = Dir(FolderPath & "*.csv*")
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each sheet In ActiveWorkbook.Sheets
sheet.copy After:=ThisWorkbook.Sheets(1)
Next sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
Application.ScreenUpdating = True
'Call copy_to_first_sheet
End Sub