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 |