工作表拆分保存为工作簿

  • A+
所属分类:好好学习

将工作表拆分保存为单独的工作薄,并以工作表名称命名:

VBA

Sub 所有工作表拆分保存为工作簿()
If MsgBox("下面操作将把所有工作表存为单独的工作簿!确定继续?", vbOKCancel, "提示信息!") = vbCancel Then
Exit Sub
End If
Dim sht As Worksheet
Application.ScreenUpdating = False
t = Timer
ipath = ThisWorkbook.path & "\"
For Each sht In Sheets
sht.Copy
ActiveWorkbook.SaveAs ipath & sht.Name & ".xlsx"
ActiveWorkbook.Close
Next
Application.ScreenUpdating = True
MsgBox "处理完毕,用时:" & Timer - t & "秒!"
End Sub

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: