Copy Template, Rename based on a reference list from a different spreadsheet
Closed
Sublimus
Posts
1
Registration date
Wednesday July 17, 2019
Status
Member
Last seen
July 17, 2019
-
Jul 17, 2019 at 07:32 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jul 18, 2019 at 02:45 AM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jul 18, 2019 at 02:45 AM
Related:
- Copy worksheet multiple times and rename
- Rename computer cmd - Guide
- Rename lg tv - Guide
- You have guessed too many times ✓ - WhatsApp Forum
- VBA Code to Copy Worksheet multiple times and rename based on list ✓ - Excel Forum
- Times attack - Download - Children
1 response
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jul 18, 2019 at 02:45 AM
Jul 18, 2019 at 02:45 AM
Hello Sublimus,
Let's assume that the new sheet names are in Sheet2, Column A starting in A2 and that you've named your template sheet "Template". Now try the following code, placed in a standard module and assigned to a button:-
This code should do as you ask and create new sheets from your Template sheet and naming them from the list in Column A of Sheet2.
Test this in a copy of your workbook first.
I hope that this helps.
Cheerio,
vcoolio.
Let's assume that the new sheet names are in Sheet2, Column A starting in A2 and that you've named your template sheet "Template". Now try the following code, placed in a standard module and assigned to a button:-
Option Explicit Sub CreateSheetsFromTemplate() Dim wsT As Worksheet Dim wsNames As Range, Rng As Range Set wsT = Sheets("Template") Set wsNames = Sheet2.Range("A2:A" & Rows.Count).SpecialCells(2) Application.ScreenUpdating = False For Each Rng In wsNames If Not Evaluate("ISREF('" & CStr(Rng.Text) & "'!A1)") Then wsT.Copy After:=Sheets(Sheets.Count) ActiveSheet.Name = CStr(Rng.Text) End If Next Rng wsT.Select Application.ScreenUpdating = True End Sub
This code should do as you ask and create new sheets from your Template sheet and naming them from the list in Column A of Sheet2.
Test this in a copy of your workbook first.
I hope that this helps.
Cheerio,
vcoolio.