Split Excel workbook into separate Files

This post will guide you how to split a large workbook to separate files and each worksheet should be saved as a single file. How do I split the whole workbook into several excel worksheets or single excel file.

Assuming that you need to split your workbook that contains lots of worksheets into multiple single Excel file and its extension name is CSV.

The simplest way is to copy each worksheet to a single excel workbook or file by manually. So you can select one worksheet that you want to save as a single excel file, then create a new workbook, paste it in the new workbook. Then save it.

If you have hundreds of worksheet in your workbook, then it will be time-consuming and tedious. So do we have a quick way to split workbook to separate excel file? Of course yes, the below will describe one way to split your workbook with VBA code.

Split Excel workbook into separate files with VBA code

Let’s see the following steps:

If you want to quickly split a large workbook into several single excel file for each worksheet, then you can write a new Excel VBA macro code to achieve the result. And the below VBA code will save the separated excel file at the directory same as with the master workbook.

1# click on “Visual Basic” command under DEVELOPER Tab.

Get the position of the nth using excel vba1

2# then the “Visual Basic Editor” window will appear.

3# click “Insert” ->”Module” to create a new module

convert column number to letter3

4# paste the below VBA code into the code window. Then clicking “Save” button.

split workbook into separate file1

Sub SplitWorkbook()
    Dim workbookPath As String
    workbookPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each wSheet In ThisWorkbook.Sheets
        Application.ActiveWorkbook.SaveAs Filename:=workbookPath & "\" & wSheet.Name & ".xlsx"
        Application.ActiveWorkbook.Close False
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

5# back to the current worksheet, then run the above excel macro. Click Run command.

split workbook into separate file2 split workbook into separate file3


Leave a Reply