Auto Name Tab based on cell

ryan_law2000

Well-known Member
Joined
Oct 2, 2007
Messages
738
Hey Everyone

I would like the tab at the bottom of the sheet to Automactially name = to cell C5
So if Cell C5 = "Ryan"
The tab at the bottom of the sheet will be named "Ryan"

Any ideas???
 

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.
If you are changing C5 manually try this. Right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "C5" Then Me.Name = Target.Value
End Sub

then press ALT + Q to return to your sheet.
 
Upvote 0
Actually I am having a minor Problem here

In My "This workbook" I have a macro like this

Private Sub Workbook_Open()
If Sheets("Pay Pd").Range("C4").Value = "" _
Then Sheets("Pay Pd").Range("C4").Value = _
InputBox("Please Enter SAP Payroll #)

If this tab changes names (which it will as soon as the name is put in) the this macro is longer valid because its not named "Pay Pd" anymore... Can I change this code above to match the tab name no matte the name?
 
Upvote 0
Check the code name - see example Fred code name is Sheet1

20091005171924.png


Then use

Code:
Private Sub Workbook_Open()
If Sheet1.Range("C4").Value = "" Then
    Sheet1.Range("C4").Value = InputBox("Please Enter SAP Payroll #")

Edit: posted 5 minutes too late!! Hiya lenze.
 
Upvote 0
This has all been very helpful and works perfect!

One more question now though lol

Can I add text before it?

example if cell C4 = Ryan

I would like the tab to say "BOT - Ryan"

So I need it to have a "BOT -" Before the name entered
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "C5" Then Me.Name = "BOT - " & Target.Value
End Sub
 
Upvote 0
what about dates?

I've used:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "C5" Then Me.Name = Target.Value
End Sub
And it works great if the cell input is formatted as text, but what about if you use a "daily report" and need the tabs to be named based off of a date entered into a cell?
 
Upvote 0
Re: what about dates?

Maybe
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address(False, False) = "C5" Then
    If IsDate(Target) Then
         Me.Name = Format(Target, "mm-dd-yy")
    Else: Me.Name = Target
    End If
End If
End Sub

lenze
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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