拆分一个Excel工作簿多个工作表成为多个Excel文件
时间:2016-10-22 08:45来源:excel.org.cn 作者:admin 点击:
次
Private Sub 分拆工作表() Dim sht As Worksheet Dim MyBook As Workbook Set MyBook = ActiveWorkbook For Each sht In MyBook.Sheets sht.Copy ActiveWorkbook.SaveAs Filename:=MyBook.Path \ sht.Name, FileFormat:=xlNormal 将工作簿另存为EX
Private Sub 分拆工作表()
Dim sht As Worksheet
Dim MyBook As Workbook
Set MyBook = ActiveWorkbook
For Each sht In MyBook.Sheets
sht.Copy
ActiveWorkbook.SaveAs Filename:=MyBook.Path & "\" & sht.Name, FileFormat:=xlNormal '将工作簿另存为EXCEL默认格式
ActiveWorkbook.Close
Next
MsgBox "文件已经被分拆完毕!"
End Sub
以上是vba代码
(责任编辑:admin) |
------分隔线----------------------------