Split Excel Worksheets to Individual Files

Earlier today I found myself putting a lot of data into a workbook with multiple worksheets within it, what I wanted to do was create an individual Excel file for each of the worksheets – perhaps you have been in a position like this yourself?

The good news, it’s very easy to do.  I came across the VBA script below and don’t take any credit for it – follow my short instructions below and you’ll find this is a very straight forward procedure.  Note this is for Microsoft Excel and does not require any third party software.

  1. Create a new folder and save your master document in there.
  2. With the document open, name each sheet the name you’d like each file to be called.
  3. Once ready, hold the ALT key on your keyboard and press F11.
  4. On the Visual Basic window, select Insert > Module.
  5. Paste the VBA script shown below.
  6. Press the F5 key on your keyboard.
  7. Job done!

Sub Splitbook()

MyPath = ThisWorkbook.Path

For Each sht In ThisWorkbook.Sheets



ActiveSheet.Cells.PasteSpecial Paste:=xlPasteValues

ActiveSheet.Cells.PasteSpecial Paste:=xlPasteFormats

ActiveWorkbook.SaveAs _

Filename:=MyPath & “” & sht.Name & “.xls”

ActiveWorkbook.Close savechanges:=False

Next sht

End Sub


Note on the fourth line from the bottom, change the .xls to .xlsx if you are working with a newer Excel format.

When I have some time, I’ll create a video demonstrating this.

34 thoughts on “Split Excel Worksheets to Individual Files

  1. I see your reply stating the below. I am on Mac High Sierra. F5 doesn't work and I am not clear on what you mean below.
    16th September 2016 – 12:52
    Bryan, are you using Windows or Mac? If on a Mac you may need to change the to a /

  2. Try this:
    I had the same issue…changed the FIlename line to the following:
    Filename:=ActiveSheet.Name & ".xlsx"

  3. I'm Sad… I get the run time error 11 division by zero. I have no idea what that means. Can you please help when you can. I placed the x in the xlsx. then I select debug and it highlight the two lines below. i'm using excel 2016 64bit

    ActiveWorkbook.SaveAs _
    Filename:=MyPath & “ ” & sht.Name & “.xlsx”

  4. I am getting the same error with sintex Filename:=MyPath & “” & sht.Name & “.xls”. could you help how to correct this?

  5. Hi Chris,

    Echoing some of the comments below:
    I am using windows and I keep getting a syntax error for:
    Filename:=MyPath & “” & sht.Name & “.xls”
    It keep highlighting the colon after file name, any ideas?


  6. Chris,

    On running the command, I am getting a compile error on the file path saying Expected:expression

    Any guidance on what I could do

  7. Just discovered this command and it would seriously save my life, but I keep seeing the following error –

    Run-time error '1004':
    Copy method of Worksheet class failed

    Debug points to sht.Copy as the error. Any suggestions?

  8. I get a run-time error '11':

    and I really want to use this script!!

    When I debug, it highlights lines 8 and 9.

    I checked my script at the link you shared with Betty above. It's just not working for me.

  9. I see your blog is in the same niche like my website. Do you allow guest posting?
    I can write interesting & unique posts for you. Let me know if you are interested.

  10. Reading your website is big pleasure for me, it deserves to go
    viral, you need some initial traffic only.

    If you want to know how to get it search for: blackhatworren's strategies

  11. Can you confirm your Excel version please Sherry? Example, Office 2013 on Windows. There are many reasons you may be getting the error message, let's first confirm the VBA code is being received correctly – can you trying again using the following link for the source? https://pastebin.com/tCeF7XMR

  12. I am getting this message, can anyone help?
    Compile error
    Must be first statement on the line
    When I press help it says below.
    Not all keywords can appear at the beginning of a line of code. This error has the following causes and solutions:

    •You preceded a Sub, Function, or Property statement with another statement on the same line. A Sub, Function, or Property statement must always be the first statement on any line in which it appears (unless preceded by the keyword Public, Private, or Static).

    •You preceded an End If, Else, or ElseIf statement with another statement on the same line. An End If, Else, or ElseIf (only when used in a block If structure) statement must always be the first statement on any line in which it appears.

  13. Change the quotation marks. Apparently when I copied over to my computer I got a different format quotation mark and spaces appeared between the . I retyped the quotation marks and eliminated the spaces. Worked after that.

  14. Excellent. Managed to extract 152 sheets into different files. The only things I have found is that, upon opening the files, I get a message stating that the file is in a different format to the file extension. Verify that the file is not corrupted and is from a trusted source before opening.

  15. This was great – you just helped me create 56 files out of one workbook. Thank you!

    The only glitch I ran into was that formulas from the original workbook didn't copy over into the new files. Is there something I can add to the VBA script that will keep the formulas intact?


  16. Hi,
    This was very helpful information, Thank you.
    Do you know how i can solve this same issue in Excel 2011 for Mac OSX?


  17. This modification worked for me, however the tab names did not carry over the files were saved as sheet1, sheet2, etc.

    Filename = MyPath & "" & sht.Name & ".xls"

  18. This one works for Mac
    Sub Splitbook()
    Dim xPath As String
    xPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each xWs In ThisWorkbook.Sheets
    Application.ActiveWorkbook.SaveAs Filename:=xPath & "" & xWs.Name & ".xlsx"
    Application.ActiveWorkbook.Close False
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub

Leave a Reply

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