Forum Discussion
ksmith
Oct 20, 2020Brass Contributor
Macro for naming sequential worksheets
I often have to create a Yearly workbook with worksheet tabs containing the names of each of the 12 consecutive months. Is there a way to create a macro to automatically do this?
ksmith
Oct 21, 2020Brass Contributor
ksmith
Oct 21, 2020Brass Contributor
Hans,
the macro worked but it did not create worksheets within my intended workbook; instead, it created a new workbook with only the sequential sheets in it. any ideas?
- HansVogelaarOct 22, 2020MVP
Your question started with "I often have to create a Yearly workbook", so the code creates a workbook...
Here is a version that adds 12 sheets to the active workbook.
Sub AddYearly() Dim wbk As Workbook Dim wsh As Worksheet Dim i As Long Application.ScreenUpdating = False Set wbk = ActiveWorkbook Set wsh = wbk.Worksheets(wbk.Worksheets.Count) For i = 1 To 12 Set wsh = wbk.Worksheets.Add(After:=wsh) wsh.Name = MonthName(i) Next i Application.ScreenUpdating = True End Sub- ksmithOct 22, 2020Brass Contributor
Hans, it worked....The created worksheets are blank but I can copy the main template into them. But, is there a syntacts that I can insert into the macro to tell it to copy my main template at the same time?
- HansVogelaarOct 22, 2020MVP
Is the main template a sheet in the same workbook in which you want the monthly sheets?
What is its name?