EXCEL 一个工作簿转多个工作簿

1.使用场景

将一个工作簿内的多个工作表转为单独的工作簿

2.使用环境

Office2016以上版本

3.语言类型

Office自带的VBA语言

4.脚本内容

Sub Save_All()
    Dim Sh As Worksheet
    Dim wb As Workbook
    Dim cPath$
    cPath = ThisWorkbook.Path & "\"
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.DisplayAlerts = False
    For Each sht In ThisWorkbook.Worksheets
        sht.Copy
        theName = sht.Name & ".xlsx"
        ActiveWorkbook.SaveAs Filename:=cPath & "\" & theName, FileFormat:=xlNormal
        ActiveWindow.Close
    Next
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub

你可能感兴趣的:(microsoft)