关于vba的工作表拆分
发布网友
发布时间:2022-04-23 00:57
我来回答
共1个回答
热心网友
时间:2023-10-09 15:54
所有工作表都不重名吗?
Sub 文件拆分()
Application.ScreenUpdating = False
p = "C:\源文件夹\" '源文件存放的路径,根据实际修改
f = Dir(p & "*.xls")
Do While f <> ""
Workbooks.Open p & f
For Each s In ActiveWorkbook.Sheets
s.Copy
ActiveWorkbook.SaveAs "C:\目标文件夹\" & s.Name & ".xls" '目标文件夹根据实际修改
ActiveWindow.Close
Next
ActiveWorkbook.Saved = True
ActiveWindow.Close
f = Dir
Loop
Application.ScreenUpdating = True
End Sub