Find and replace sheet names

mccdaddy

Board Regular
Joined
Apr 7, 2002
Messages
72
Hi. I have a workbook with a sheet for each month so they're named 1.2023 thru 12.2023. I want to update the sheet names for 2024. Must I select each tab and rename them or is there a way to do a Find and Replace from 2023 to 2024? I see information about replacing sheet names in formulas but nothing about the tabs themselves.

Thanks for any help.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If VBA is an option, you could try this code in the Worksheet module:
VBA Code:
Private Sub UpdateSheetNames()
Dim s As Worksheet
For Each s In Sheets
    s.Name = Replace(s.Name, "2023", "2024")
Next s
End Sub
 
Upvote 0
Solution
I have very little experience with VBA. I pasted your code in a module and saved it with an .xlsm extension but when I go to run the macro no name appears. What am I doing wrong?
 
Upvote 0
Place the code in the "ThisWorkbook" module

1726180096031.png


Put your cursor right before the "Private Sub" and click the green "Run Sub/Userform" button.
1726180190026.png
 
Upvote 0
Actually, I suppose the module doesn't matter. Just click the green "run sub" button with your cursor at the top of the sub.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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