Problem renaming worksheet

P

Patrick C. Simonds

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
 
P

Peter T

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
 

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

Top