Forum Discussion
Rename multiple sheets in Excel workbook
- Philip WestAug 22, 2018Iron Contributor
hia,
this should work.. you will need to add it as a module and then run it..
It will change the name of every worksheet in the workbook, starting with the most left sheet and working right.
Sub rename()
Dim Mydate As Variant
Mydate = InputBox("dd/mm/yy")
For Each sht In ThisWorkbook.Worksheets
sht.Name = Format(Mydate, "dd-mm-yy")
Mydate = DateAdd("d", 1, Mydate)
Next sht
End SubIt will ask you for a date to start, I know it works with dd/mm/yy so use that.. if you want the date format of the name to be different then you can edit the line:
sht.Name = Format(Mydate, "dd-mm-yy") change the date mask to match what you want.. just remember that you cant use / as that's an illegal character in sheet names.
Normal warnings.. make sure you have a copy of your workbook saved before you press any buttons.. there is no undo with VBA. There is also no error checking with this, so if you do edit the mask and add something it doesn't like it will just fail.
Hope that helps.
- katie.holadayAug 22, 2018Copper Contributor
Thank you SOOOOOO much!!! That saves me so much time : ) IT WORKED
- Philip WestAug 22, 2018Iron Contributor
:)
glad it worked for you.