![](https://img.haomeiwen.com/i14700486/3a65e4a859d6e072.png)
![](https://img.haomeiwen.com/i14700486/c0ede601387c2818.png)
将Execl Workbooks文件夹内的3个表格合并到File文件中。打开File文件,通过写VBA代码来实现。
![](https://img.haomeiwen.com/i14700486/59982458ad4f2377.png)
![](https://img.haomeiwen.com/i14700486/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
网友评论