Heelertreats
New Member
- Joined
- Jan 8, 2021
- Messages
- 6
- Platform
- Windows
Noob here. I've seen some questions that are close to this (split sheets two at a time, etc), but I haven't found exactly what I need yet. Hoping y'all can help me out.
I have a button set up that dynamically creates new worksheets based on data in sheet3. I have a second button that splits each of those worksheets into its own separate workbook. What I lack is that the new workbooks should always include sheet2 as well as the dynamically generated sheet.
Example:
Original workbook sheets: Template | Lookups | Master
After I enter values in sheet Master: Template | Lookups | Master | new1 | new2 | new3 | etc
After I hit my "split" button, all of the new workbooks have only one tab: new1 or new2 or new3 etc
Instead, I'd like the sheet Lookups to be included in the split with each of the other new sheets, such that each new workbook has these sheets: Lookups | new1, or Lookups | new2, or Lookups | new3
I'm going to post my existing VBA . It might not be pretty....
I look forward to your insights!
I have a button set up that dynamically creates new worksheets based on data in sheet3. I have a second button that splits each of those worksheets into its own separate workbook. What I lack is that the new workbooks should always include sheet2 as well as the dynamically generated sheet.
Example:
Original workbook sheets: Template | Lookups | Master
After I enter values in sheet Master: Template | Lookups | Master | new1 | new2 | new3 | etc
After I hit my "split" button, all of the new workbooks have only one tab: new1 or new2 or new3 etc
Instead, I'd like the sheet Lookups to be included in the split with each of the other new sheets, such that each new workbook has these sheets: Lookups | new1, or Lookups | new2, or Lookups | new3
I'm going to post my existing VBA . It might not be pretty....
VBA Code:
Sub SplitEachWorksheet()
Dim FPath As String
FPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Sheets
If ws.Name <> "TEMPLATE" And ws.Name <> "Lookups" And ws.Name <> "MASTER" Then
ws.Copy
Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & "_PFC.xlsx"
Application.ActiveWorkbook.Close False
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
I look forward to your insights!