Set up a Master sheet in your workbook, and add month sheets automatically, based on that Master sheet. The new sheets will be named for the month and year, in yyyy_mm format.
Add Month Sheets Automatically
This video shows the steps for setting up the master sheet and macros, to add month sheets automatically in a workbook. Written details are below the video.
Create a Master Sheet
The first step is to set up a Master sheet in your workbook. In my sample file, the sheet is named wkst_Master.
It has a named Excel table, tblSales, starting in cell A1.
Master Sheet Freeze Pane
To save time in the new sheets, be sure that the Master sheet is set up exactly the way you want it.
In my sample file, there is a Freeze Pane setting, with the first row frozen at the top.
This keeps the table’s heading row visible, when you scroll down on the sheet.
Master Sheet Selected Cell
Another setting that I made on the Master sheet was to select cell A1. It’s a minor thing, but it saves you the time of selecting that cell on each new sheet that’s created.
Macro to Add Month Sheets
In the sample file, there is a macro to add month sheets automatically, as needed.
This macro, named AddMonthWkst, is stored on a regular code module, named modSheets, and does the following steps:
- sets the sheet which will be used as the Master
- calculates the current year and month name, in yyyy_mm format
- checks for a sheet with that year/month name
- if not found, it creates a new sheet, based on Wkst_Master
- names new sheet with current year and month
Macro Code to Add Month Sheets
Here is the code for the AddMonthWkst macro.
NOTE: You can change the master sheet name, and the date formatting, to match what you need in your workbook.
Sub AddMonthWkst() Dim ws As Worksheet Dim wsM As Worksheet Dim strName As String Dim bCheck As Boolean On Error Resume Next Set wsM = Sheets("Wkst_Master") strName = Format(Date, "yyyy_mm") bCheck = Len(Sheets(strName).Name) > 0 If bCheck = False Then 'add new sheet after Instructions wsM.Copy After:=Sheets(1) ActiveSheet.Name = strName End If Set wsM = Nothing End Sub
Workbook Open Code
To make that macro run automatically when the workbook opens, there is code in the ThisWorkbook module too.
The code is in the Workbook_Open event, and all it does is run the AddMonthWkst macro.
Private Sub Workbook_Open() AddMonthWkst End Sub
Test the Month Sheets Macro
After you add the Workbook_Open code and the AddMonthWkst macro code to your workbook, close the workbook, and then open it again.
If a security warning appears, click Enable Content, to allow the macros to run.
Then, if the workbook doesn’t already have a sheet for the current month, a new sheet will be automatically added, named with the year and month.
Get the Sample File
To see how the code works, and add month sheets automatically, get my sample file from my Contextures website.
Go to the Excel Worksheet Macros page, and get the sample file from the Download section.
___________________________
Add Month Sheets Automatically
___________________________
Hi! This worked great for my workbook, but I am wanting to take it further still. I have a Master sheet (Loans Template) and it has generated the 07_2020 worksheet for me. It is copying over all of the data that I am entering into the Master sheet, but here is what I am wanting to do if it is possible to add into your code above:
If a loan in July’s worksheet (named 07_2020) is not marked in column J as “Closed” before August’s worksheet generates, I would want that row’s entire data to be copied over to the next available row on August’s worksheet when it is created, thus copying the previous month’s worksheet instead of the blank Master worksheet each month.
My data starts in cell A4 and can be input through cell K52.
I have 8 other options besides “Closed” in column J that can be chosen from. I can provide those if necessary.
Please let me know if you are able to help, I would greatly appreciate it!
This has worked great for us. What we would also like to do is carry forward the last entry of one month to be the starting entry of the next month. Is the a way to do this please? The last entry is not always in the same cell, but always in the same column.
Thanks, this is great, how do I do this for a weekly sheet?
I am looking for the same solution. could you please help me out
This works great, but I wanted to add report daily. I need a new sheet with date to add daily when I open?
Is it possible?