Help with marcro; copy tabs based on list

endlessboundless

New Member
Joined
Jan 27, 2011
Messages
33
Hello,

Looking for some help regarding a macro, hope someone can please help.

So I have a list on a sheet named "input" which users can populate with department names (eg 1, 2, 3, ect). I also have a blank template called "template". I would like a macro that would duplicate the template tab and rename the tab based on the department names entered. So in the example above, "template" would be duplicated 3 times and the names of the tabs would be 1, 2 and 3.

TYIA,
Amit
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try this one. You might have to change a few things to match your specifics, but should do the trick.

Code:
Sub Copysheets()

'Makes sure you're on the right sheet
'change to match whatever sheet name has the list on it
Sheets("StartSheet").Select

'Sets active sheet as a variable for easy reference
StartSheet = ActiveSheet.Name

'Moves to the first cell in the list
'change to match the first cell in list range
Range("A1").Select

'Loops through the list, copying the template sheet to a new sheet at the end
'and renames it the value from the list
Do While ActiveCell.Value <> ""
SheetName = ActiveCell.Value
Sheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = SheetName
Sheets(StartSheet).Select
ActiveCell.Offset(1, 0).Select
Loop

End Sub

HTH.
 
Upvote 0
Thanks you very much, worked like a charm.

If you could help me, I've posted another question regarding an existing macro that I have. Could you help with this aswell?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

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