VBA Code to Copy Worksheet multiple times and rename based on list
Solved/Closed
Related:
- Excel vba copy sheet and rename based on list
- Vba copy sheet - Best answers
- Vba copy sheet and rename with date - Best answers
- Number to words in excel without vba - Guide
- Rename computer cmd - Guide
- Enable vba in excel - Guide
- My contacts list names - Guide
- How to screenshot excel sheet - Guide
2 responses
vcoolio
Posts
1404
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 15, 2023
259
Dec 31, 2020 at 08:08 AM
Dec 31, 2020 at 08:08 AM
Hello Hpence,
I'm assuming that the "Master" sheet is your template sheet which you are wanting to copy and the list of names to name each new sheet is in Column A of the "Dates" sheet starting in cell A1. If this is correct, then changing/adding to your code a little as follows should work for you:-
This code will create a new sheet based on the "Master" sheet for each unique name in Column A of the "Dates" sheet without duplication.
Please test the code in a copy of your actual workbook.
I hope that this helps.
Cheerio,
vcoolio.
I'm assuming that the "Master" sheet is your template sheet which you are wanting to copy and the list of names to name each new sheet is in Column A of the "Dates" sheet starting in cell A1. If this is correct, then changing/adding to your code a little as follows should work for you:-
Option Explicit Sub CopySheet() Dim wsM As Worksheet Dim wsNames As Range, c As Range Set wsM = Sheets("Master") Set wsNames = Sheets("Dates").Range("A1:A" & Rows.Count).SpecialCells(2) Application.ScreenUpdating = False For Each c In wsNames If Not Evaluate("ISREF('" & c.Value & "'!A1)") Then wsM.Copy After:=Sheets(Sheets.Count) ActiveSheet.Name = c.Value End If Next c wsM.Select Application.ScreenUpdating = True End Sub
This code will create a new sheet based on the "Master" sheet for each unique name in Column A of the "Dates" sheet without duplication.
Please test the code in a copy of your actual workbook.
I hope that this helps.
Cheerio,
vcoolio.
Sep 4, 2021 at 02:03 PM