Hi
I have a set of tabs that I want to split into workbooks. See below which works.
However I also want to put a ref tab, (the same one) in each new workbook, along with the series of tabs.
Stumped.
First problem, is that even if I could code it, Excel doesn't support multiple tabs copy, if they contain tables, which mine do.
So that leaves me with how to either create the new book and copy the Ref tab and then the individual tab, or create the individual new workbooks and then copy the ref tab in, in a second routine. Both currently beyond me.
Any help? Much appreciation for any guidance.
Sub MoveSheetsToWorkbooks()
Dim ws As Worksheet, strFilepath As String, pathForSave As String
Dim wb As Workbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
pathForSave = "mypathtosaveto\"
For Each ws In ActiveWorkbook.Worksheets
If ws.name <> "Index" Then
ws.Activate
savename = ws.name
ws.Copy
ActiveWorkbook.SaveAs pathForSave & savename & ".xlsx"
ActiveWorkbook.Close
End If
Next ws
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I have a set of tabs that I want to split into workbooks. See below which works.
However I also want to put a ref tab, (the same one) in each new workbook, along with the series of tabs.
Stumped.
First problem, is that even if I could code it, Excel doesn't support multiple tabs copy, if they contain tables, which mine do.
So that leaves me with how to either create the new book and copy the Ref tab and then the individual tab, or create the individual new workbooks and then copy the ref tab in, in a second routine. Both currently beyond me.
Any help? Much appreciation for any guidance.
Sub MoveSheetsToWorkbooks()
Dim ws As Worksheet, strFilepath As String, pathForSave As String
Dim wb As Workbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
pathForSave = "mypathtosaveto\"
For Each ws In ActiveWorkbook.Worksheets
If ws.name <> "Index" Then
ws.Activate
savename = ws.name
ws.Copy
ActiveWorkbook.SaveAs pathForSave & savename & ".xlsx"
ActiveWorkbook.Close
End If
Next ws
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub