VBA Code to Copy Worksheet multiple times and rename based on list
Solved/Closed
Related:
- Vba worksheet copy and rename
- Vba duplicate sheet and rename - Best answers
- Vba copy sheet and rename - Best answers
- Rename computer cmd - Guide
- Rename lg tv - Guide
- Lg tv rename inputs ✓ - Smart TV Forum
- You have guessed too many times ✓ - WhatsApp Forum
- Times attack - Download - Children
2 responses
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
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