cell E5 to be worksheet name

bluepenink

Well-known Member
Joined
Dec 21, 2010
Messages
585
Hello

is it possible to have cell E5 become the worksheet or tab name?

currently cell E5 = John Doe's Performance (Revenue)

so i would like the worksheet name to equal that...can someone pls help!

thx u!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Need VBA...

Try this
Code:
Sub NameSheet()
ActiveSheet.Name = Range("E5").Value
End Sub
 
Upvote 0
lol pls excuse my anglish there :)

E5 = John Doe

I want the worksheet/tab name to be John Doe.

If i change John Doe, to Michael Jordon, I would like if it can change itself. thx you for your help sir!
 
Upvote 0
to make it happen automatically when you change the value in E5, try

Right click on the Sheet's Tab, View code
Paste the following

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$5" Then
    On Error Resume Next
    Me.Name = Target.Value
    If Err.Number = 1004 Then
        MsgBox "Invalid Sheet Name"
        Application.Undo
    End If
    On Error GoTo 0
End If
End Sub

now when you change the value of E5, the sheet's name will change with it.
Hope that helps.
 
Upvote 0
Need VBA...

Try this
Code:
Sub NameSheet()
ActiveSheet.Name = Range("E5").Value
End Sub

hello

im not that good with macros, if i want this for a partiular worksheet, i.e. Sheet4....how can i re-work the macro?

and am i going to insert this on each worksheet in VBA or a module? thx u
 
Upvote 0
If you want it to happen for ALL sheets, then put this in the module named "ThisWorkBook"

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$E$5" Then
    On Error Resume Next
    Sh.Name = Target.Value
    If Err.Number = 1004 Then
        MsgBox "Invalid Sheet Name"
        Application.Undo
    End If
    On Error GoTo 0
End If
End Sub
 
Upvote 0
much appreciated. thx u

is it possible to have & or - included

basially, one of my worksheets is called
John Doe's Performance Rev & Est

and it gives me an error whenever i try to use & or - or + etc

thx u
 
Upvote 0
It's not the symbols that are the problem, it's the length.
Limit is 31 characters.
You're only over it by 1.

For your example, I would recommend removing the apostrophe '

Sheet names with apostrophes can cause nightmares in subsequent programming.
 
Upvote 0
Hello

i used the following code

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
  On Error GoTo Rename_Error
  If Target.Address = "$E$5" And Len(Target.Value) <> 0 Then _
    Sh.Name = Target.Value
  Exit Sub
Rename_Error:
  MsgBox "The sheet name could not be renamed. Please check " & vbCrLf & _
        "that you did not use illegal characters."
End Sub

my file is password protected thru a macro and when i opened the workbook, it does not change the worksheet name, even if the worksheet is unproctected...any suggestions?
 
Upvote 0
Of coarse it doesn't change the sheet name when you open file.
It only changes the sheet name when the value in E5 changes.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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