Rename Tabs

-emma-

Board Regular
Joined
Jul 14, 2006
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am using a spread sheet which contains a "CoverSheet" tab naming 6 different people. Cells A2 - A7 hold names of people. The spread sheet contains another 6 tabs each labled the same as cells A2 - A7. Unfortunatly I change the names in cells A2 - A7 on a regular basis and would like the tab names to automaticly change too.

Any ideas anyone? Any suggestions would be helpful.

Thanks,

Emma
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hello Emma, welcome to the board.
You can use a bit of vba for that.
Insert a standard module and put this into it.
Public OldName As String

Put this into the sheet module for CoverSheet.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then OldName = "": Exit Sub
If Not Intersect(Target, Range("A2:A7")) Is Nothing Then _
  OldName = Target.Value
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("A2:A7")) Is Nothing Then Exit Sub

If OldName <> "" And Target.Value <> OldName Then
  Dim Sheet As Worksheet
  For Each Sheet In Worksheets
    On Error GoTo ErrTrp
    If Sheet.Name = OldName Then Sheet.Name = Target.Value
  Next Sheet
End If
Exit Sub

ErrTrp:
If Err.Number = 1004 Then
  MsgBox "There is already a sheet named '" & Target.Value & "'." & Chr(10) & _
         "Please choose a name not currently being used."
  Target.Value = OldName
Else
  MsgBox Err.Number & ": " & Err.Description
End If
         
End Sub
 
Upvote 0
You're welcome. Glad it helped.
Please check the code you have against what's posted there now as I had made
a few changes to make it a bit more robust and I don't know if you got the
latest version or the original. :wink:
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,040
Members
448,543
Latest member
MartinLarkin

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