我有16个工作簿,每月都会将数据放到文件夹中。我想创建一个VBA宏,它将复制每个工作簿中的所有工作表并将它们放入一个主工作簿中。这样我就可以整理数据并发送给相关人员。这可能吗?
答案 0 :(得分:0)
通过简单的Google搜索引导您访问此网页:How To Combine Multiple Workbooks To One Workbook In Excel?。在那里你找到了这个代码:
Sub GetSheets()
Path = "C:\Users\lazy\Desktop\S08\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub