Save all worksheets to separate files in the current folder (the one this workbook is in) using sheet names as file names.

Anne Troy

MrExcel MVP
Joined
Feb 18, 2002
Messages
2,632
Office Version
  1. 365
Platform
  1. Windows
I have tried using many different macros out there, and none of them work, or they stopped working for no apparent reason. I have 10 worksheets, and one macro saved only 3 worksheets as sheet1... sheet2 instead of the names I assigned. I opened them, and they were all empty. Some just did nothing. One saved as sheet1, sheet2 in my XLSTART folder, when the path was clearly defined.

I'd love the simplest code, no dialogs, no error handling... it's just for me to use. Anybody? Please?

Let me know if you have any questions.
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Here's the code that only gives me the first 3 sheets.

VBA Code:
Sub SplitEachWorksheet()
Dim FPath As String
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"
    Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hey, Queen! :-)

The current code uses ThisWorkbook, it is supposed to be Activeworkbook. Please try the following.

VBA Code:
Sub SplitEachWorksheet()
Dim FPath As String
Dim ws as Worksheet
    FPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each ws In ActiveWorkbook.Sheets
        ws.Copy
        ActiveWorkbook.SaveAs FileName:=FPath & "\" & ws.Name & ".xlsx"
        ActiveWorkbook.Close False
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

(Isn't this just like 20+ years ago? It feels like yesterday!)
 
Upvote 0
Solution
Hey, Queen! :)

The current code uses ThisWorkbook, it is supposed to be Activeworkbook. Please try the following.

VBA Code:
Sub SplitEachWorksheet()
Dim FPath As String
Dim ws as Worksheet
    FPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each ws In ActiveWorkbook.Sheets
        ws.Copy
        ActiveWorkbook.SaveAs FileName:=FPath & "\" & ws.Name & ".xlsx"
        ActiveWorkbook.Close False
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

(Isn't this just like 20+ years ago? It feels like yesterday!)
The like button has no heart!! Trying it now...
 
Upvote 0
Of course it works beautifully!! Thank you PumpKing!
 

Attachments

  • images.jpg
    images.jpg
    8.2 KB · Views: 3
Upvote 0
Thank you PumpKing!
LOL! 🎃

By the way, there are new features on the forum now. Please click on the checkmark right next to the post that answered your question to mark it as solution. This way, the other visitors looking for a similar title will know this question has a solution.

1690412498942.png


The like button has no heart!! Trying it now...
There is also a giant heart right above it!! LOL!

Nice to see you, Anne. Always. 😍
 
Upvote 0
Marked Solved!

Are you busy? I need a macro that takes THIS worksheet, and separates into a worksheet for 10 zones (or each unique zone) in the column H. I have no code for that and only keep finding making sheets from cell values.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top