Split Each Excel Sheet Into Separate Files (Manual + VBA)

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

Last updated

If you have an Excel workbook with many worksheets, there is no easy way to split each of these sheets into separate Excel files and save separately.

This could be needed when you have sheets for different months or regions or products/clients, and you want a separate workbook for each sheet (as an Excel file or as a PDF).

There is a manual way to do this, which works fine for a few sheets. But with a lot of sheets, it’s slow and error-prone.

In this tutorial, I will show you the manual way, and then give you a simple VBA code that splits all the worksheets into their own separate files (or PDFs) in a few seconds.

Follow along with the example file

Split Each Excel Sheet Into Separate Files.xlsx

Download

Split Sheets Into Separate Files Manually (Without VBA)

If you only have a handful of sheets, you don’t need any code. You can copy each sheet into a new workbook and save it.

Below I have a workbook with six sheets of bakery sales, one for each month, and I want each sheet saved as its own Excel file.

Excel workbook with six monthly sales sheets from 2025 Jan to 2026 Mar

Here are the steps to save one sheet as a separate Excel file:

  1. Right-click on the sheet tab that you want to save as a separate file (2025 Jan in this example), and click on Move or Copy.
Right-click menu on the 2025 Jan sheet tab with Move or Copy highlighted
  1. In the Move or Copy dialog box, click the ‘To’ drop-down and select (new book).
Move or Copy dialog box with (new book) selected in the To drop-down
  1. Check the ‘Create a copy’ option and click OK.
Create a copy option checked in the Move or Copy dialog box

Excel opens a new workbook that has only this one sheet in it.

Important: If you leave ‘Create a copy’ unchecked, Excel moves the sheet out of your main file instead of copying it.

  1. Press the F12 key (Cmd + Shift + S on a Mac) to open the Save As dialog box, and go to the folder where you want to save the file.
Save As dialog box opened with the F12 key
  1. Type the file name (such as 2025 Jan) in the File name field and click Save.
2025 Jan typed as the file name in the Save As dialog box

Now close this new workbook, go back to your main file, and repeat these steps for every other sheet.

If you select multiple sheet tabs (hold Ctrl, or Cmd on a Mac, and click them) and then use Move or Copy, all of them go into one new workbook together.

That’s handy, but you end up with one file that has all those sheets in it.

With six sheets, this is manageable. With 30 or 50 sheets, it gets tedious and it’s easy to skip or misname one, and that’s where the VBA code below helps.

If you only need to copy one sheet somewhere, here’s more on how to copy a worksheet in Excel. You can also copy a sheet to a new workbook using VBA.

Split Each Worksheet Into a Separate Excel File Using VBA

Below I have the same workbook with a worksheet for each month, and I want every sheet saved as its own Excel file in one go.

Workbook with a separate sheet for each month that will be split using VBA

To split these sheets into separate Excel files, you can use the below VBA code:

'Code Created by Sumit Bansal from trumpexcel.comSub SplitEachWorksheet()Dim FPath As StringDim ws As ObjectFPath = ThisWorkbook.PathApplication.ScreenUpdating = FalseApplication.DisplayAlerts = FalseFor Each ws In ThisWorkbook.Sheets    If ws.Visible = xlSheetVisible Then        ws.Copy        Application.ActiveWorkbook.SaveAs Filename:=FPath & Application.PathSeparator & ws.Name & ".xlsx"        Application.ActiveWorkbook.Close False    End IfNextApplication.DisplayAlerts = TrueApplication.ScreenUpdating = TrueEnd Sub

There are a few things you need to make sure before using the above VBA code:

  1. Create a folder where you want to get all the resulting files.
  2. Save the main Excel file (which has all the worksheets that you want as separate files) in this folder.

Once you have this done, then you can put the above VBA code in the file and run the code.

The above code is written in a way that it picks up the location of the folder using the path of the file (in which the code is run).

This is why it’s important to save the file in the folder first and then use this code.

How does the VBA code work – The above code uses a simple For Next loop that goes through each worksheet and creates a copy of the worksheet in a new Excel workbook.

It then saves this workbook in the specified folder (which is the same that has the main file with all the sheets) and closes it.

The code only splits visible sheets. Excel can’t copy a hidden sheet into a new workbook on its own, so the code skips hidden sheets instead of stopping with an error.

If you want a hidden sheet split too, unhide the sheets before you run the code.

It also uses Application.PathSeparator instead of a hard-coded backslash, so the file path gets the right separator whether you’re on Windows or a Mac.

Important: If the folder already has a file with the same name as a sheet, the codes in this tutorial overwrite it without asking.

Below are the steps to place this VBA code in the Excel workbook (these will be same for all the other methods shown in this tutorial).

Where to put this code?

Below are the steps to place the code in the Visual Basic Editor where it can be executed:

  1. Click the Developer tab.
Developer tab in the Excel ribbon
  1. In the Code group, click on the Visual Basic option. This will open the VB Editor. [You can also use the keyboard shortcut – ALT + F11]
Visual Basic option in the Code group of the Developer tab
  1. In the VB Editor, right-click on any of the objects of the workbook you’re working on.
Right-click on a workbook object in the Project Explorer of the VB Editor
  1. Hover the cursor over the Insert option and click on Module. This will insert a new module.
Insert and then Module selected from the right-click menu in the VB Editor

This also opens the code window for the module. If it doesn’t, double-click on the Module object to open it.

  1. Copy the VBA code provided above and paste it in the module code window.
VBA code to split each worksheet pasted in the module code window
  1. Select any line in the code and click on the green play button in the toolbar to run the VBA macro code.
Green Run button in the VB Editor toolbar

The above steps would instantly split the worksheets into separate Excel files and save these.

It takes only a second if you have a few worksheets. In case you have a lot, it may take some time.

The name of each saved file is the same as that of the sheet name it had in the main file.

Folder showing a separate Excel file for each sheet, named after the sheet

Since you have placed a VBA code in the Excel workbook, you need to save this with a .XLSM format (which is the macro-enabled format).

This will ensure the macro is saved and works when you open this file next.

Note that I have used the lines Application.ScreenUpdating = False and Application.DisplayAlerts = False in the code so that everything happens in the backend.

This way, you don’t see things happening on your screen.

Once the code runs and splits the sheets and saves these, we turn these back to TRUE.

As a best practice, it’s recommended to create a backup copy of the main file (which has the sheets that you want to split).

This will ensure you don’t lose your data in case anything goes wrong or if Excel decides to become slow or crash.

If a sheet has formulas that refer to other sheets, those formulas become external links to your main file in the new files (the manual method does this too).

If you want the new files to hold plain values instead, add this line right after the ws.Copy line in the code:

ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value

This converts every formula to its value in the copied sheet, so do this only when the split files don’t need live formulas.

Also, use it only when the workbook has no chart sheets, as a chart sheet has no cells and stops the code with an error.

VBA doesn’t run in Excel for the web, so you need the desktop version of Excel (Windows or Mac) for all the codes in this tutorial.

Also read: Inserting Excel Tables Into Word

Follow along with the example file

Split Each Excel Sheet Into Separate Files.xlsx

Download

Split Each Worksheet and Save as Separate PDFs

Below I have the same workbook with one sheet for each month, and this time I want each sheet saved as its own PDF file.

Workbook with monthly sheets that will be saved as separate PDFs

In case you want to split the worksheets and save these as PDF files instead of the Excel files, you can use the below code:

'Code Created by Sumit Bansal from trumpexcel.comSub SplitEachWorksheetToPDF()Dim FPath As StringDim ws As ObjectFPath = ThisWorkbook.PathApplication.ScreenUpdating = FalseFor Each ws In ThisWorkbook.Sheets    If ws.Visible = xlSheetVisible Then        ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FPath & Application.PathSeparator & ws.Name & ".pdf"    End IfNextApplication.ScreenUpdating = TrueEnd Sub

Things you need to make sure before using this code:

  1. Create a folder where you want to get all the resulting files.
  2. Save the main Excel file (which has all the worksheets that you want as separate files) in this folder.

The above code splits each sheet in the Excel file and saves it as a PDF in the same folder where you have saved the main Excel file.

Unlike the previous code, this one doesn’t need to copy each sheet into a new workbook first. It exports every visible sheet straight to a PDF named after the sheet.

Each PDF uses the page setup of its sheet (print area, orientation, and margins).

So set the print area and layout first if you want the PDFs to look a certain way.

Pro Tip: Each code in this tutorial has its own name, so you can paste all of them into the same module and run whichever one you need.

Also read: Insert Pdf Into Excel

Split Only Sheets That Contain Specific Text Into Separate Files

In case you have a lot of sheets in a workbook and you only want to split those sheets that have a specific text in their name, you can do that as well.

For example, suppose you have an Excel file where you have data for multiple years and each sheet in the file has the year number as the prefix. Something as shown below:

Sheet tabs with 2025 and 2026 year prefixes in the workbook

Now, let’s say you want to split all the sheets for 2026 and save these as separate Excel files.

To do this, you need to somehow check the name of each worksheet, and only those sheets that have the number 2026 should be split and saved, and the rest should be left untouched.

This can be done using the following VBA macro code:

'Code Created by Sumit Bansal from trumpexcel.comSub SplitSheetsContainingText()Dim FPath As StringDim TexttoFind As StringDim ws As ObjectTexttoFind = "2026"FPath = ThisWorkbook.PathApplication.ScreenUpdating = FalseApplication.DisplayAlerts = FalseFor Each ws In ThisWorkbook.Sheets    If ws.Visible = xlSheetVisible And InStr(1, ws.Name, TexttoFind, vbBinaryCompare) <> 0 Then        ws.Copy        Application.ActiveWorkbook.SaveAs Filename:=FPath & Application.PathSeparator & ws.Name & ".xlsx"        Application.ActiveWorkbook.Close False    End IfNextApplication.DisplayAlerts = TrueApplication.ScreenUpdating = TrueEnd Sub

In the above code, I have used a variable TexttoFind, which has been assigned to “2026” in the beginning.

The VBA code then uses the For Next loop in VBA to go through each worksheet and check the name of each worksheet using the INSTR function.

This function checks whether the worksheet name has the text 2026 in it or not. If it does, it will return a position number where it finds this text (which is 2026 in this case).

And if it doesn’t find the text we are looking for, it returns 0.

This is used with the IF Then condition. So if a sheet name has the text string 2026 in it, it will be split and saved as a separate file.

And if it doesn’t have this text string, the IF condition would not be met and nothing would happen. In this example, you get three files: 2026 Jan, 2026 Feb, and 2026 Mar.

Pro Tip: vbBinaryCompare makes the match case-sensitive. If you’re matching a word like “Sales”, change it to vbTextCompare so “sales” and “SALES” also match.

So these are the ways you can split each Excel sheet into separate files, either manually or with a simple VBA code, as Excel files or as PDFs.

I hope you found this Excel tutorial useful.

You may also like the following Excel tutorials:

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

14 thoughts on “Split Each Excel Sheet Into Separate Files (Manual + VBA)”

  1. I am trying to run the split worksheets macro. I have run it before on other computers. When i try to run it on my new computer the macro stops at the
    ws.Copy
    portion. Any ideas why it is stopping?

    Reply
    • I had same experience. I used the same code perfectly splitting a workbook into individual files. But next time I used it, it error @ the WS.COPY with a runtime 1004.

      Reply
  2. Thank you, the video and the instructions were very clear and easy to follow. The code worked perfectly!

    Reply
  3. I just want to say thank you! I’m just starting to learn VBA. So I appreciate not only the succinct code but the clear explanation of why some steps are necessary.

    I have a inventory report with 86 separate tabs of 15,000+ rows with terrible formatting. Having them all as their own file will make the next steps to append into a single table and transform with power query so much easier.

    Reply
  4. I am trying to split and worksheet into 2 sheets each with the Names Scrap Yard, Faircrest, and Harrison. I would like to know how to do this too, please.

    Reply
  5. When I copied your VBA for splitting my worksheet, I get an error on the first line. Sub SplitEachWorksheet() is hsow in the macro box name as Sheet2.SplitEachWorkbook. The vba will not run. What am I doing wrong?

    Sub SplitEachWorksheet()
    Dim FPath As String
    Dim TexttoFind As String
    TexttoFind = “Scrap Yard”
    FPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    For Each ws In ThisWorkbook.Sheets
    If InStr(1, ws.Name, TexttoFind, vbBinaryCompare) 0 Then
    ws.Copy
    Application.ActiveWorkbook.SaveAs Filename:=FPath & “” & ws.Name & “.xlsx”
    Application.ActiveWorkbook.Close False
    End If
    Next

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub

    Reply
  6. If I copy the code to PERSONAL macro book it is not working. I need to copy the code in a specific sheet of a workbook and execute. Why? Can you provide a macro that works independently?

    Reply

Leave a Comment

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.