Renaming Excel Sheets month on month using VBA

navnav21

New Member
Joined
Jun 2, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi I have about 100 excel sheets in a workbook that i need to rename in the format "01.01.2011" , "01.02.2011" , "01.03.2011" and so on until the last sheet is renamed. Can someone please help me on how to do this using VBA please?

Thank you in advance!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this:

VBA Code:
Sub DoTheThing()

Dim ws As Worksheet
Dim myDate As Date

myDate = "01/01/2011"

For Each ws In ThisWorkbook.Worksheets
    ws.Name = Format(myDate, "DD.MM.YYYY")
    myDate = DateAdd("m", 1, myDate)
Next ws

End Sub
 
Upvote 0
Hi Thank you so much it worked. But when i ran it again, there was some error as they said "this name is taken"

1622698856189.png

1622698875298.png


What do I do? Thank you very much for the earlier help once again.
 
Upvote 0
It simply means you already have a worksheet by that name ....but, why would you want to run it more than once ??
 
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

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