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!
 
hello

thx for your prompt response.

in cell E5 on sheet1, the cell =D5&" District Performance"
where D5 is drop down selection of Q2, Q3, Q4

when i change that, it changes in E5, but not in the formula.

is it how i have my macro, in this workbook?

Code:
Private Sub Workbook_Open()
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True
        .EnableOutlining = True
    End With
Next c
End Sub
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
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
hello

the code above works, however, i need to go into the cell i.e. E5 and press enter for the worksheet to be refreshed.

is it possible for the macro to auto refresh?
 
Upvote 0
OK, it's not working because the code is triggered by manual change of the value in E5. Not via formula in E5.

If it's D5 that is manually changed by the dropdown, try

Rich (BB code):
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
  On Error GoTo Rename_Error
  If Target.Address = "$D$5" And Len(Target.Value) <> 0 Then _
    Sh.Name = Sh.Range("E5").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

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

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