How to Automatically Rename 52 Excel Worksheets with Weekly Dates
Question details
The user needs a way to automatically rename 52 worksheets in an Excel workbook with consecutive weekly Sunday dates for the year 2023.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing a weekly tracking workbook that contains 52 sheets, where manually renaming each sheet to a specific date is too time-consuming.
- Observed behavior
- The goal state is to execute a script or process that programmatically assigns a formatted date (such as the Sunday of each week) to each of the 52 worksheets without utilizing invalid characters like slashes.
Before running the macro, ensure your workbook actually contains at least 52 blank or existing worksheets to avoid script errors, and always save a backup copy of your file.
Use a VBA Macro to Rename Sheets Automatically
Using a simple VBA script is the fastest and most reliable way to batch rename multiple sheets with incrementing dates in Excel.
Excel worksheet names cannot contain certain characters like slashes (/). The macro formats the dates with hyphens (e.g., 1-Jan-2023) to comply with this naming rule and ensure the script runs smoothly.
Press the ALT + F11 keys simultaneously on your keyboard to open the Microsoft Visual Basic for Applications (VBA) window.
From the top menu, click 'Insert' and select 'Module'. This will open a blank window where you can write or paste your code.
Copy and paste the following code into the module window: Sub NameSheets() Dim i As Long Dim d As Date Application.ScreenUpdating = False d = DateSerial(2023, 1, 1) For i = 1 To 52 Worksheets(i).Name = Format(d, "d-mmm-yyyy") d = d + 7 Next i Application.ScreenUpdating = True End Sub
Press F5 or click the 'Run' button (the green play icon) on the top toolbar. Return to your workbook to see the first 52 sheets instantly renamed.
Automate Your Workflow Seamlessly with WPS Spreadsheet
WPS Spreadsheet offers robust tools to organize, format, and manage large workbooks effortlessly. You can natively run macros and handle advanced formatting without missing a beat.
- 1. Open Your Workbook: Launch WPS Spreadsheet and open your existing file containing the 52 worksheets.
- 2. Access Developer Tools: Navigate to the 'Developer' tab on the top ribbon to access the built-in Macro tools.
- 3. Open the VBA Editor: Click 'Macros' and open the VBA Editor to insert a new code module.
- 4. Run the Automation: Paste your custom date-generation macro code and click 'Run' to batch rename your sheets in seconds.

Frequently Asked Questions
Why do I get an error when naming an Excel sheet with a date?
Excel restricts certain characters in worksheet names, including slashes (/), backslashes (\), asterisks (*), and question marks (?). Always use hyphens (-) or periods (.) when formatting dates for sheet names to prevent naming errors.
How can I change the date format in the VBA macro?
You can modify the format string in the 'Format' function within the code. For example, changing "d-mmm-yyyy" to "yyyy-mm-dd" will format the date as 2023-01-01 instead of 1-Jan-2023.
What happens if I have fewer than 52 sheets when running the macro?
The macro will produce a 'Subscript out of range' error when it tries to rename a sheet index that does not exist in the workbook. Ensure you have the exact number of sheets specified in the loop, or adjust the 'For i = 1 To 52' line to match your actual sheet count.
How do I start on a different day of the week instead of Sunday?
You simply need to adjust the DateSerial(year, month, day) function in the VBA code to correspond to the exact calendar date of the specific day you want to start on.




