Sub SplitWorksheetsByName()

Dim wb As Workbook
Dim ws As Worksheet
Dim newWb As Workbook
Dim newWs As Worksheet
Dim sheetName As String
Dim savePath As String

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
    sheetName = ws.Name
    Set newWb = Workbooks.Add
    Set newWs = newWb.Sheets(1)
    ws.Copy newWs
    newWs.Name = sheetName
    savePath = wb.Path & "\" & sheetName & ".xlsx"
    newWb.SaveAs savePath
    newWb.Close
Next ws

End Sub

用VBA拆分工作表,按工作表表名进行拆分

原文地址: https://www.cveoy.top/t/topic/wvP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录