Automatically renaming worksheets and copying a template

blairta

New Member
Joined
Jun 10, 2015
Messages
2
Hello,

This is my first post to this forum so please forgive me if I make a posting mistake. I am fairly proficient with Excel except when it comes to macros, coding, vba, etc. so I am at a loss right now on how to proceed.

I have a workbook with contains 2 tabs, the first is "Staff List" which contains employee names starting in cell A2. The second tab is "Template" which contains a form that I need for each employee. What I am wondering is if there is anyway for Excel to produce a new tab, one per employee on the list and copy the template into this tab for each? This would be done at April 1st of each year, but then there could be additions through the fiscal year (April 1 to March 31).

I have searched this site as well as others for solutions, each one that I found refers to coding which has worked to a point, but then it seems to be a one time use only, the macro will not work if I need to add a name to the list at a later date and as I said my skills with macros is limited so I am not sure how to proceed.

I would appreciate any assistance and insight. If this is something that Excel just can't do then I can accept that and find another solution to work on.

Regards, Blair
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Go to VBE (Alt + F11)
On the Menu go to Insert > Module
and paste the following code on the main pane

Code:
Sub MoreTemplate()
    lr = Worksheets("Staff List").Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Sheets("Template").Copy after:=Sheets(Sheets.Count)
        Worksheets("Template (2)").Name = Worksheets("Staff List").Range("A" & i).Value
    Next i
End Sub
 
Upvote 0
Go to VBE (Alt + F11)
On the Menu go to Insert > Module
and paste the following code on the main pane

Code:
Sub MoreTemplate()
    lr = Worksheets("Staff List").Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Sheets("Template").Copy after:=Sheets(Sheets.Count)
        Worksheets("Template (2)").Name = Worksheets("Staff List").Range("A" & i).Value
    Next i
End Sub

Thank you iggydarsa, the code works great and does exactly what I need it to do, the only other issue is if I need to add an staff name at a later date the code will not work, is there someway around this problem? I hope so, if not I will work on an alternate plan. Thank you again for the code that you did send, it will work at the beginning of each year.

Blair
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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