Create Sheets with a cell name and based on a template

cmdoasm

New Member
Joined
Sep 9, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello! I'm looking for a macro that can create a new sheet for all entries in a specific column based on a template. I know how to run the new tabs with the correct names, but I can't seem to figure out how to make those new sheets a copy of the template. For reference, my master sheet with all of the data is named "MASTER" and my template is named "TEMPLATE". The tab names are in column "A" and all of the formula's use a VLOOKUP formula to fill in the template with their respective row's data (on the master sheet). Below is the code that I am currently using to create the new sheets with the correct tab names, I just can't figure out how to make those new worksheets use the template.


'Name macro
Sub CreateSheets()
'Dimension variables and declare data types
Dim rng As Range
Dim cell As Range
'Enable error handling
On Error GoTo Errorhandling
'Show inputbox to user and prompt for a cell range
Set rng = Application.InputBox(Prompt:="Select cell range:", _
Title:="Create sheets", _
Default:=Selection.Address, Type:=8)
'Iterate through cells in selected cell range
For Each cell In rng
'Check if cell is not empty
If cell <> "" Then
'Insert worksheet and name the worksheet based on cell value
Sheets.Add.Name = cell
End If
'Continue with next cell in cell range
Next cell
'Go here if an error occurs
Errorhandling:
'Stop macro
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Replace
VBA Code:
Sheets.Add.Name = cell

With
VBA Code:
Worksheets("Template").Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
 
Upvote 0
Solution

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top