Me would refer to the workbook owning the code (since you're in the ThisWorkbook
module).
Try:
sh.range("a1")
(since that sh is getting passed to the subroutine.)
Don't forget to change this line, too:
Me.Name = Range("A1").Text
to
sh.Name = sh.Range("A1").Text
And if you were using the equivalent code within a worksheet module, you would
have been ok.
Max wrote:
Gord, tried as suggested, with the sub below placed in the ThisWorkbook
module. Testing on any sheet with an entry in A1 resulted in a compile error:
Method or data member not found. The ".Range" in Me.Range("A1") was
highlighted. Anything I can do to get this going ? Thanks.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
Me.Name = Range("A1").Text
CleanUp:
Application.EnableEvents = True
End Sub
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Gord Dibben" wrote:
Max
I thought about later last night and realized I had posted code for just one
worksheet and OP wanted all worksheets.
Was going to re-post this morning so here goes.
Enter this in the Thisworkbook module not in a sheet module.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'enter event code here
End Sub
Will cover all sheets.
Gord
--
Dave Peterson