ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Code to Change the Tab Name (https://www.excelbanter.com/excel-discussion-misc-queries/136663-vba-code-change-tab-name.html)

Michael in Texas

VBA Code to Change the Tab Name
 
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!

Mike

VBA Code to Change the Tab Name
 
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


"Michael in Texas" wrote:

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!



All times are GMT +1. The time now is 06:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com