本文为《别怕,Excel VBA其实很简单(第3版)》随书问题参考答案
如果保存Excel文件的目录为D:\VBA其实很简单\,可以使用下面的过程:
Sub 合并工作表()
Application.ScreenUpdating = False
Dim FileName As String, Sht As Worksheet, Wb As Workbook
FileName = Dir("D:\VBA其实很简单\*.xls?")
Do While FileName ""
Workbooks.Open FileName:="D:\VBA其实很简单\" & FileName
Set Wb = ActiveWorkbook
For Each Sht In Wb.Worksheets
Sht.Copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
Next Sht
Wb.Close savechanges:=False
FileName = Dir
Loop
Application.ScreenUpdating = True
End Sub
声明:本站所有文章均出自互联网,只为学习之用;如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)