Multiple excel workbooks into a single workbook

14700486-3a65e4a859d6e072.png

14700486-c0ede601387c2818.png

The Execl Workbooks folder within the three tables merged into File file. Open File file, be accomplished by writing VBA code.


14700486-59982458ad4f2377.png

14700486-81c4ece509766cf3.png
Private Sub 点击合并_Click()
'需要合并的表格文件夹存放位置
Path = "C:\Users\15432\Desktop\Excel Workbooks\"
'文件名
Filename = Dir(Path & "*.xlsx")
'取文件循环
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
'sheet选择
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy after:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub

Guess you like

Origin blog.csdn.net/weixin_33778544/article/details/90889640