Skip to main content

How to export and save each worksheet as separate new workbook in Excel?

Let's say you want to export and save one or several worksheets as a new workbook, how will you deal with it? Normally you may copy each worksheet and paste to new workbook. But here we bring you some handy tricks to deal with it:

Export and save worksheets as new workbook with Move or Copy command

Export and save worksheets as new workbook with VBA code

Export and save worksheets as new workbook with Kutools for Excel good idea3


arrow blue right bubble Export and save worksheets as new workbook with Move or Copy command

Using the Move or Copy command will help you export or copy one or several worksheets to a new workbook quickly.

Step 1: Select the worksheet names in tab bar. You can select multiple with holding down Ctrl key or shift key.

Step 2: Right click the worksheet name, and click the Move or Copy from context menu.
doc export sheets 1

Step 3: In Move or Copy dialog box, select the (new book) item from the drop down list of Move selected sheets to book.

doc export sheets 2

Step 4: Then click OK, now you have switched to the new workbook with exported or copied worksheets, click File > Save to save the new workbook.

Note: In the Move or Copy dialog box, there is a Create a copy option. If you do not check it, it will move the selected worksheets out of original workbook; if check it, it will copy selected worksheets.


Quickly split multiple worksheets into separate workbook in Excel

In Microsoft Excel, you can save or split a worksheet from one workbook as a new Excel file by copying and pasting this worksheet into a new workbook. It seems troublesome, if you want to split each sheet / worksheet of a large workbook as separate Excel, txt, csv, pdf files. But with Kutools for Excel’s Split Workbook utility, you can quickly deal with it.  Click for 30 days free trial with full features!
doc split workbook 1
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

arrow blue right bubble Export and save worksheets as new workbook with VBA code

This following code will export every visible worksheet in a new workbook and save the workbook with the name of the original sheet in a newly created folder in the same path as the active workbook. Please do as following steps:

Step 1: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

Step 2: Click Insert > Module, and paste the following macro in the Module Window:

VBA : Export and save worksheets as new workbook in a new folder.

Sub SplitWorkbook()
'Updateby20200806
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim xWs As Worksheet
Dim xWb As Workbook
Dim xNWb As Workbook
Dim FolderName As String
Application.ScreenUpdating = False
Set xWb = Application.ThisWorkbook

DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = xWb.Path & "\" & xWb.Name & " " & DateString

If Val(Application.Version) < 12 Then
    FileExtStr = ".xls": FileFormatNum = -4143
Else
    Select Case xWb.FileFormat
        Case 51:
            FileExtStr = ".xlsx": FileFormatNum = 51
        Case 52:
            If Application.ActiveWorkbook.HasVBProject Then
                FileExtStr = ".xlsm": FileFormatNum = 52
            Else
                FileExtStr = ".xlsx": FileFormatNum = 51
            End If
        Case 56:
            FileExtStr = ".xls": FileFormatNum = 56
        Case Else:
            FileExtStr = ".xlsb": FileFormatNum = 50
        End Select
End If

MkDir FolderName

For Each xWs In xWb.Worksheets
On Error GoTo NErro
    If xWs.Visible = xlSheetVisible Then
    xWs.Select
    xWs.Copy
    xFile = FolderName & "\" & xWs.Name & FileExtStr
    Set xNWb = Application.Workbooks.Item(Application.Workbooks.Count)
    xNWb.SaveAs xFile, FileFormat:=FileFormatNum
    xNWb.Close False, xFile
    End If
NErro:
    xWb.Activate
Next

    MsgBox "You can find the files in " & FolderName
    Application.ScreenUpdating = True
End Sub

Step 3: Press the F5 key to run this code. And a prompt box will pop up to tell you the location of the new exported workbooks, and all of the worksheets of the original workbook have been exported to some new separate workbooks which named original sheets in a new specific folder. See screenshots:

doc export sheets 7

arrow blue right bubble Export and save worksheets as new workbook with Kutools for Excel

If you have multiple worksheets needed to be saved as separate workbook, the first method cannot be a good choice. And the VBA code maybe a little complicated for Excel beginners. Here you can use the Split Workbook utility of Kutools for Excel to quickly and easily export and save each worksheet of one workbook to separate new workbook.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

Step 1: Click Kutools Plus > Workbook > Split Workbook…. See screenshot:
doc export sheets 3

Step 2: In the Split Workbook dialog box, do as below:

doc export sheets 4
1: all of the worksheet names have been checked by default, if you don’t want to split some of the worksheets, you can uncheck them;


2: If you want to avoid splitting the hidden or blank worksheets, you can check the Skip hidden worksheets or Skip blank worksheets.);


3: and also you can check Specify save format, and to select split the sheets then save as text file, pdf file, or csv file, in defualt, if you do not check this option, it will split sheets and save as workbook.

Step 3: Then click Split button, and choose the folder that you want to put the new workbooks to. See screenshot:
doc export sheets 6

Step 4: And then click OK, then each checked worksheet in the Split Workbook dialog box is exported and saved as individual workbook. Each new workbook is named with the original worksheet name. See screenshot:
doc export sheets 5

Click to know more information about this Split Workbook tool.

arrow blue right bubble Export and save each sheet as new workbook


Quickly split data into multiple worksheets based on column or fixed rows in Excel

Supposing you have a worksheet that has data in columns A to G, the salesman’s name is in column A and you need to automatically split this data into multiple worksheets based on the column A in the same workbook and each salesman will be splitted into a new worksheet. Kutools for Excel’s Split Date utility can help you to quickly split data into multiple worksheets based on selected column as below screenshot shown in Excel.  Click for full-featured 30 days free trial!
doc split data 2
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

Related articles:

Best Office Productivity Tools

Supercharge Your Spreadsheets: Experience Efficiency Like Never Before with Kutools for Excel

Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns     Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolset12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   Many More...

Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...

Supports Office/Excel 2007-2021 & newer, including 365   |   Available in 44 languages   |   Enjoy a full-featured 30-day free trial.

kte tab 201905


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

Comments (63)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thanks, this was awesome. There are dozens of pages on the internet talking about how to do this. You guys are the only ones that got the VBA code right. Many thanks. I had a big monster workbook with about 100 tabs, all relatively small, and the VBA macro knocked it out in about five minutes. Thank God for smart guys like you. :)
Rated 5 out of 5
This comment was minimized by the moderator on the site
This has been extremely helpful, my job was doing some data management manually and this helped me automate it. I do have a question though, as the code is a bit over my head to figure out on my own.

What would I need to change to make it so that it always saves as a CSV file instead of an excel file? I know it'll be part of the IF VAL THEN CASES but I don't follow the formatting of that area.

Thank you,
Matt
This comment was minimized by the moderator on the site
Hi, Matt, I am glad that this article can help you. If you want to save sheets as new CSV files, this article https://www.extendoffice.com/documents/excel/5537-excel-batch-convert-to-csv.html lists the methods on exporting sheets as separated CSV files, hope it can do you a favor.
This comment was minimized by the moderator on the site
I have been using this VBA Code for some time and it worked like a charm until I changed computers. I have the same version of excel but now I am getting a Run Time Error "76" Path Not found. Any ideas what could be causing this? It looks like it is hanging up at MkDir. Any help you can provide is appreciated.
This comment was minimized by the moderator on the site
Hi, can I ask which office version you use?
This comment was minimized by the moderator on the site
I'm having this issue as well. I ran it once a month ago just fine and this came up just now.
This comment was minimized by the moderator on the site
You are amazing! Thank you so very much!
This comment was minimized by the moderator on the site
Thank you so much ! great and useful.
This comment was minimized by the moderator on the site
For Each xWs In xWb.Worksheets
How to do export only selected / grouped sheets to separate excel sheets by using this code.?
This comment was minimized by the moderator on the site
Hi there,

Keep getting a pop up that says 'compile error, invalid outside procedure' when i try and run the code. Any thoughts? Thanks for all your help.
This comment was minimized by the moderator on the site
Hi, Issybeee, I have update the VBA code in the tutorial, you can try the new one again.
This comment was minimized by the moderator on the site
For those of you who save macros in your "Personal.XLSB" or XLSTART (I see more questions below related to this), change the line

Set xWb = Application.ThisWorkbook to

Set xWB = ActiveWorkbook

That will make the macro run from the Active Workbook instead and save in a subfolder to that.
This comment was minimized by the moderator on the site
With the first method, if I hit F5, it opens a pop up window with the function "Go to". My excel is in spanish, im not sure if that is a factor. Any idea on how to fix it?
This comment was minimized by the moderator on the site
You can directly click the Run button of the Microsoft Visual Basic for Applications window.
This comment was minimized by the moderator on the site
Un aporte realmente útil. He probado el módulo con código VBA y funciona a la perfección. Muchas gracias, me has salvado una tarea que me hubiera llevado mucho tiempo con el mover y copiar.
This comment was minimized by the moderator on the site
This is a fantastic piece of work, thanks a lot.
Do we have any option to select only specific columns in a worksheet to be exported?
This comment was minimized by the moderator on the site
Hi, SS, if you want to export a specific selection as a individual file, this article can help you https://www.extendoffice.com/documents/excel/626-excel-save-selection.html
This comment was minimized by the moderator on the site
For anybody who finds the VBA code is not running as expected, try to change Line 9 to "Set xWb = Application.ActiveWorkbook"

Otherwise, fantastic! Does exactly as described, and runs fairly quickly
This comment was minimized by the moderator on the site
very nice.... Thanks
This comment was minimized by the moderator on the site
How to convert this macro so that I can save it in my personal workbook and can use to where ever I need it.
This comment was minimized by the moderator on the site
Click Developer tab > Record Macro > select Personal Macro Workbook, and give the vba a name.
Then in Microsoft Visual Basic for Applications window, click VBAProject(PERSONA_XLSB) > Modules > double click Module1, paste the code between Sub() and End Sub, save the code.
When you want to use the code, click Developer > Macro, choose the code you name.
This comment was minimized by the moderator on the site
xWs.Copy this methode give me an erreor 1004
This comment was minimized by the moderator on the site
February 2019 - after some update Excel silently exits macro right after Application.ActiveWorkbook.SaveAs
It means, that commands Application.ActiveWorkbook.Close does not run and file stays opened... Could it be fixed? This happened all the machines in our office on several workbooks that were using such kind of Macro.
This comment was minimized by the moderator on the site
Do you have the formula to make sure that each excel sheet when saved as a new work book is in total format Comma Delimited .CSV
This comment was minimized by the moderator on the site
Sorry, I have no idea,neither.
This comment was minimized by the moderator on the site
Love this and another info you have on splitting data into each worksheet. However I keep getting an error when trying to upload my single reports into my system

I needed them as a csv file so just changed the last part of the module to .csv I am wondering if I missed something else that should've been changed.

Thanks a million
This comment was minimized by the moderator on the site
what is the use of Worksheet.Save??
This comment was minimized by the moderator on the site
to save the changes made
This comment was minimized by the moderator on the site
What? I do not understand.
This comment was minimized by the moderator on the site
Hi Sunny,

Thank you for sharing this code!

I keep getting this error "Compile Error: Wrong number of arguments or invalid property assignment" at the "format" portion of the following string:

DateString = format(Now, "yyyy-mm-dd hh-mm-ss")
This comment was minimized by the moderator on the site
Hi, I use this VBA code all the time to separate commission statements into individual spreadsheets. Is it possible to add a line to the code so it will automatically email the report to each person using outlook?
This comment was minimized by the moderator on the site
Soryy I did not know a code can do that, but you can split the workbook first, then apply Kutools for Excel's Create Mailing List and Send Emails utilities to create a mailing list, and then send the reports as attachments to each person. For more detail, please go to visit this article https://www.extendoffice.com/product/kutools-for-excel/excel-create-mailing-list-and-send-email.html
This comment was minimized by the moderator on the site
i cant find enterprise toolbar kindly help me
This comment was minimized by the moderator on the site
this code cahnge dates in my sheets
This comment was minimized by the moderator on the site
What dates have been changed? The modified dates? The Enterprise tab will be appeared after installing Kutools for Excel.
This comment was minimized by the moderator on the site
xWs.Copy line comes up with an error in my case with 2016 "Method 'Copy of object'_Worksheet' failed.
Please suggest me a correction if possible.
This comment was minimized by the moderator on the site
Sorry, I have no idea about your problem.
This comment was minimized by the moderator on the site
Hi,


its totally work with the excel 2010.


however, after i upgraded to Excel 2016, the code doesn't work.


would you please advise which part should i be revised?
This comment was minimized by the moderator on the site
Excuse me, which method you cannot use in Excel 2016? In my condition, all of the methods above do work in Excel 2016 perfectly
This comment was minimized by the moderator on the site
Hi the second method worked great. Thank you. I have one question. This method saves each worksheet as a new workbook based on the name of the sheet. Is there anyway to add to the name, for example sheets have a variable name which is currently being saved. Can I add January 2017 or Feb 2017 to the files saved?
This comment was minimized by the moderator on the site
Thanks for your leaving message, you can apply Kutools for Excel's Rename Multiple Worksheets to rename every sheets of the workbook firstly, then use one of above methods to export or save the sheets separately as workbook. If you want to know more detail on Rename Multiple Worksheet utility, please visit this:https://www.extendoffice.com/product/kutools-for-excel/batch-rename-excel-worksheets.html
This comment was minimized by the moderator on the site
Is there a way to change this macro so I can save it in a file in the XLSTART folder but it will run for the active workbook? Everytime I save it in the XLSTART workbook it fails at the DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")line. Thanks! Sarfraz
This comment was minimized by the moderator on the site
This is exactly what I needed! Awesome!
This comment was minimized by the moderator on the site
Hi. I received an error code that says "Compile error: Invalid outside procedure"...help!
This comment was minimized by the moderator on the site
Your code worked for me... Thanks much!!!
This comment was minimized by the moderator on the site
Can we also export ALL (300+) sheets to html, this will help me a lot, the export to unified text is already helping but I need them in html, or no table borders for the cell differences
This comment was minimized by the moderator on the site
Out of the above three methods, I found the first method to be quite good having regard to the fact that I am a beginner & my work is not at all of the same magnitude like professionals. My sincere thanks for explaining the steps in simple and lucid manner.
This comment was minimized by the moderator on the site
Run time error Method 'Copy of Object' worksheet' failed
This comment was minimized by the moderator on the site
xWs.Copy -it is an error in my part what does it mean?
This comment was minimized by the moderator on the site
Great article - VBA worked first time - perfect
This comment was minimized by the moderator on the site
Unfortunately the VBA code didn't work for me. I had to debug and the issue is with the line: Application.ActiveWorkbook.SaveAs xFile, FileFormat:=FileFormatNum Any ideas why it didn't work for me?
This comment was minimized by the moderator on the site
Muy buena la aplicacion. Es una pena no existir tambien en Español. Gracias
This comment was minimized by the moderator on the site
Very Useful thanks! Loved the VBA Code
This comment was minimized by the moderator on the site
thank. terimakasih. ini code yang saya butuhkan
This comment was minimized by the moderator on the site
The VBA codes works like magic, but is there a way for this to be done using VBScript? I'm going nuts trying to meet the requirement from my supervisor.
This comment was minimized by the moderator on the site
this code is perfect for what i need, but could you show code for the exact same process for one sheet rather than the entire workbook?
This comment was minimized by the moderator on the site
The code is failing at sh.Copy and I cannot figure out why. Any Ideas?
This comment was minimized by the moderator on the site
Thank you. This is esactly what I needed.
This comment was minimized by the moderator on the site
Hi All, Can someone help me on below. I need VBA code that can copy only all visible sheets to new workbook and it should not copy macro code to new workbook, save new workbook on desktop with two different cell values in sheet and sheet name as a file name and close the master workbook without saving.
This comment was minimized by the moderator on the site
Is there a way to change this macro so I can save it in a file in the XLSTART folder but it will run for the active workbook? Everytime I save it in the XLSTART workbook it fails at the DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")line. Thanks! Keith
This comment was minimized by the moderator on the site
Thanks a lot. Good Job!.
This comment was minimized by the moderator on the site
Hello I like the code Is it possible to just save the new workbook without the date information That is so when I resave the sheets in the previous workbook I will have the option to overwrite the changes rather than create another dated folder? Also but not so important how could I use another name and destination for the destination folder Regards Sean
This comment was minimized by the moderator on the site
thanks alot, works very well and easy.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations