Was trying to find an automated way of saving all my different Excel Sheets into a single separate file.

Office scripts was not able to do it so end up having to use VBA coding.

Press ALT + F11

Copy and Paste VBA codes to Module

Save As file type *.xlsm (macro workbook)

VBA code Start

Sub SplitEachWorksheet()

    Dim FPath As String

    Dim ws As Worksheet

    FPath = Application.ActiveWorkbook.Path

    Application.ScreenUpdating = False

    Application.DisplayAlerts = False

    For Each ws In ThisWorkbook.Sheets

        ws.Copy

        Application.ActiveWorkbook.SaveAs Filename:=FPath & “\” & ws.Name & “.xlsx”, FileFormat:=xlOpenXMLWorkbook

        Application.ActiveWorkbook.Close False

    Next

    Application.DisplayAlerts = True

    Application.ScreenUpdating = True

End Sub

VBA code Ends

Leave a Reply

Your email address will not be published. Required fields are marked *