HELP with Sheet names

danaeann

New Member
Joined
Nov 22, 2015
Messages
2
I am working on a spreadsheet that has a master sheet named weekly chart and a lot of other sheets named by dates. On the weekly chart sheet I have dates that I change each time I send the spreadsheet out. When I change these dates I want it to change all the sheet names on the remaining sheets. I am new to VBA codes and can't figure out what code to use and how to make it update when I change the dates. An example spreadsheet would be awesome if someone could e-mail one to me!!! Thank you!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi danaeann and welcome to the Board.

Excel "spits-up" if you try and name a sheet with a date including the "/" separator.. So If you don't mind your sheets with your dates like 12-4-2015, 12-11-2015, etc then here's a way to do what you want...

Here a SAMPLE FILE as you asked for.. Beginning with your Master Sheet..
Excel 2012
AB
1
2My Current
3Sheet Name
4Dates
512/4/2015
612/11/2015
712/18/2015
812/25/2015
9
10

<tbody>
</tbody>
Weekly Chart



Switch to the VBA App and in the WeeklyChart Code Window (Not a Standard Module Window) Paste in the following Code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Intersect(Target, Range("B5:B8")) Is Nothing Then
Exit Sub
End If
Select Case Target.Address
    Case Is = "$B$5"
    Worksheets(2).Name = Replace(Target.Value, "/", "-")
    Case Is = "$B$6"
        Worksheets(3).Name = Replace(Target.Value, "/", "-")
    Case Is = "$B$7"
        Worksheets(4).Name = Replace(Target.Value, "/", "-")
    Case Is = "$B$8"
        Worksheets(5).Name = Replace(Target.Value, "/", "-")
End Select
End Sub

Be sure to Create as many sheets (beforehand) on the number of sheets you refer to in your Weekly Chart Sheet (4 currently)...

You could HIDE the Weekly Chart Sheet so it is not VISIBLE to the Users --

Test it out by entering NEW DATES in any of THE 4 CELLS ON YOUR WEELKY CHART SHEET - Watch the corresponding Sheet Names change as you do...
Maybe this will get you started... Jim
 
Last edited:
Upvote 0
Yes that works! Thank you so much! The only issue I am having now is that when I change the start date in b5 and auto fill the remaining 120 days it wont update the sheet names. But if I manually change each date it does update the sheet name. Is there a way to use the code by autofilling the dates in b5-b125 without manually entering each date?
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

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