Worksheets into Workbook
Solved/Closed
Game Start Now
Posts
138
Registration date
Thursday January 21, 2010
Status
Member
Last seen
May 8, 2019
-
Dec 30, 2016 at 03:09 AM
Game Start Now Posts 138 Registration date Thursday January 21, 2010 Status Member Last seen May 8, 2019 - Jan 2, 2017 at 03:15 PM
Game Start Now Posts 138 Registration date Thursday January 21, 2010 Status Member Last seen May 8, 2019 - Jan 2, 2017 at 03:15 PM
Related:
- Worksheets into Workbook
- Run macro on opening workbook - Guide
- Excel vba add sheet to another workbook - Guide
- Transfer data from one excel workbook to another automatically - Guide
- Macro to copy data from another workbook - Guide
- How to copy macros from one workbook to another - Excel Forum
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Updated by TrowaD on 2/01/17 at 11:52 AM
Updated by TrowaD on 2/01/17 at 11:52 AM
Hi GSN,
This is what I got for you:
Here is the code:
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
This is what I got for you:
- The name of the new workbook will be the one of the sheet that is copied to it.
- The new workbook is saved in the same folder as your starting file.
- All worksheets that are password protected will remain so.
- The empty sheet is deleted on code line 16. In English it's called "Sheet1". Don't know if you use an english version, otherwise you need to change the sheets reference.
Here is the code:
Sub RunMe() Dim ws As Worksheet Dim shName As String For Each ws In Worksheets If ws.Name <> "NMS" And ws.Name <> "MS" And _ ws.Name <> "Master" And ws.Name <> "Missing" Then ws.Select shName = ws.Name Workbooks.Add ThisWorkbook.ActiveSheet.Copy _ after:=ActiveWorkbook.Sheets(Sheets.Count) Application.DisplayAlerts = False Sheets("Sheet1").Delete Application.DisplayAlerts = True ThisWorkbook.Sheets("NMS").Copy _ after:=ActiveWorkbook.Sheets(Sheets.Count) ThisWorkbook.Sheets("MS").Copy _ after:=ActiveWorkbook.Sheets(Sheets.Count) ThisWorkbook.Sheets("Master").Copy _ after:=ActiveWorkbook.Sheets(Sheets.Count) ThisWorkbook.Sheets("Missing").Copy _ after:=ActiveWorkbook.Sheets(Sheets.Count) ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path _ & "\" & shName & ".xlsx" ActiveWorkbook.Close End If Next ws End Sub
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
Jan 2, 2017 at 03:15 PM