ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem renaming worksheet (https://www.excelbanter.com/excel-programming/406553-problem-renaming-worksheet.html)

Patrick C. Simonds

Problem renaming worksheet
 
The code below is intended to change the name of the Active Worksheet to the
Value in cell A4. But I get an "object or With variable not set"




Private Sub Worksheet_Change(ByVal Target As Range)

Dim Sh As Worksheet

If Target.Address = "$A$4" Then
Const sStr As String = "A4"


ActiveSheet.Name = Sh.Range(sStr).Value


End If

End Sub


Peter T

Problem renaming worksheet
 
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$4" Then
Me.Name = Target(1)
End If

End Sub

Regards,
Peter T

"Patrick C. Simonds" wrote in message
...
The code below is intended to change the name of the Active Worksheet to

the
Value in cell A4. But I get an "object or With variable not set"




Private Sub Worksheet_Change(ByVal Target As Range)

Dim Sh As Worksheet

If Target.Address = "$A$4" Then
Const sStr As String = "A4"


ActiveSheet.Name = Sh.Range(sStr).Value


End If

End Sub





All times are GMT +1. The time now is 04:46 PM.

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