Change Sheet Names Based on Cell Value

mykulpasskwa

Board Regular
Joined
Mar 20, 2018
Messages
66
I have a calculator named "Calc" that is a dashboard for 4 different semesters--Fall, Spring, Summer 1, Summer 2. The main sheet is Calc and each semester has its own datasheet, so there are 5 sheets total.

Depending on what population we're calculating I need the tabs to update accordingly. So, if its changed the semester tab changes to Fall, Winter, Spring, Summer

For example, the standard workbook is the Calc sheet and Fall, Spring, Summer 1, Summer 2. If we click on "Night school" I want the tabs to change to Fall, Winter, Spring, Summer. I have it setup with a formula where if "Night School" is selected then cell G9 changes to "Winter". If G9 changes to Winter, I want the tab to change to Winter. Also, if it is toggled back to Spring, I want it to change back to Spring. Basically I would like it to reflect whatever cell G9 has.

I've looked at a few codes around the internet already, but they keep changing the Calc tab and not the semester that should change.

Anyone have any ideas out there?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
On the sheet you want this to happen, right click on the tab and VIEW code,

Copy and paste this in:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$9" Then
If Trim(Range("G9")) <> "" Then
ActiveSheet.Name = Range("G9")
End If
End If
End Sub

This doesn't error trap if you put a bogus name in G9
 
Upvote 0
On the sheet you want this to happen, right click on the tab and VIEW code,

Copy and paste this in:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$9" Then
If Trim(Range("G9")) <> "" Then
ActiveSheet.Name = Range("G9")
End If
End If
End Sub

This doesn't error trap if you put a bogus name in G9

Thanks for the response. I'm not having much luck though. I pasted it into the Spring worksheet, which needs to change to Winter when G9 changes from Spring to Winter. When I paste it and run it nothing happens and then if I try to walk through it, it asks which macro I want to run.
 
Upvote 0
Thanks for the response. I'm not having much luck though. I pasted it into the Spring worksheet, which needs to change to Winter when G9 changes from Spring to Winter. When I paste it and run it nothing happens and then if I try to walk through it, it asks which macro I want to run.

Hmm, so you went to the Spring worksheet, right click on the tab, VIEW CODE, copy and past in my code. Close.
Go to G9 and change to Winter (or however G9 is changed)???
 
Upvote 0
Hmm, so you went to the Spring worksheet, right click on the tab, VIEW CODE, copy and past in my code. Close.
Go to G9 and change to Winter (or however G9 is changed)???

Yeah, so that was my mistake. I ended up toying with it until it worked. If I tried to Run Sub it would prompt for a macro which was throwing me off, but if I just changed the G9 cell it worked perfectly. Thanks for the help! Greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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