Sheet Name Change

jlawrenz

New Member
Joined
Apr 26, 2011
Messages
4
Can you set a sheet to change the sheet name to whatever is in a particular cell?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You need VBA for this. Assuming the sheet name is in Cell A1 of the sheet, right-click the sheet tab and select View Code. Then paste the code below into the white space in the VBA editor that opens.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then Me.Name = Target.Value
End Sub
Each time a new name is entered in A1, the sheet tab name will change.
 
Upvote 0
That worked. I use excel to do my construction daily logs. Everyday I copy the last days daily sheet and I rename the sheet that days date. I want it to change when I put the days date in the log.

That VBA work but I had to put the date with dots (1.1.10) I couldn't use - or /
 
Upvote 0
You need VBA for this. Assuming the sheet name is in Cell A1 of the sheet, right-click the sheet tab and select View Code. Then paste the code below into the white space in the VBA editor that opens.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then Me.Name = Target.Value
End Sub
Each time a new name is entered in A1, the sheet tab name will change.

What if the cell is on a different worksheet?

I have looked through the forums and haven't been able to find the answer.

I have cells B21:B25 in Sheet1 that I want to use to name the worksheet names for Sheet2:Sheet6.

Thanks.
 
Upvote 0
What if the cell is on a different worksheet?

I have looked through the forums and haven't been able to find the answer.

I have cells B21:B25 in Sheet1 that I want to use to name the worksheet names for Sheet2:Sheet6.

Thanks.
Put this code into a module for Sheet1. Note there's no error trapping in this, so you need to avoid making duplicate entries in cells B21:B25 on sheet1.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B21:B25"), Target) Is Nothing Then
    For Each sh In ThisWorkbook.Sheets
        If Len(sh.CodeName) = 6 Then
            If Right(sh.CodeName, 1) Like "[2-6]" Then
                sh.Name = Range("B21").Offset(Val(Right(sh.CodeName, 1)) - 2, 0).Value
            End If
        End If
    Next sh
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

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