怎么把EXCEL中的工作表分别单独建立一个表格,以工作表名字为文件名

2024-12-29 13:01:58
推荐回答(1个)
回答1:

搞定了,添加一个宏,把代码拷进去就OK了,我这已经试过了.

Sub Macro1()
Dim xName(1 To 100) As String, exe As String
exe = ActiveWorkbook.Name
MsgBox exe
Dim s As Worksheet
i = 1
For Each s In Worksheets
xName(i) = s.Name
MsgBox xName(i)
i = i + 1
Next
i = 1
Do Until xName(i) = ""
Worksheets(xName(i)).Select
Worksheets(xName(i)).Copy
ActiveWorkbook.SaveAs "D:\1\" & xName(i) & ".xlsx"
ActiveWorkbook.Close
Windows(exe).Activate
i = i + 1
Loop
End Sub