excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
I found this code to split worksheets into separate workbooks:
How do I modify it based on two criteria:
1) I want all the split workbooks to be saved into a different folder
2) I only want selected worksheets to be split into separate files
Thanks.
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
How do I modify it based on two criteria:
1) I want all the split workbooks to be saved into a different folder
2) I only want selected worksheets to be split into separate files
Thanks.