VBA Code to Change the Tab Name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code that someone helped me with yesterday that is used
to change the name of the tab to whatever name is in cell "C1.":

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("C1"), Target) Is Nothing Then
Exit Sub
End If
v = Target.Value
ActiveSheet.Name = v
End Sub

The problem is that is seems to work sometimes and then will stop. Or it
won't work when I try to copy the page, etc.

Is there some trick I'm missing? Thanks!
 
Try this and remember you can't have tabs with same name

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C1").Value = "" Then End
ActiveSheet.Name = Range("C1").Value
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top