sheet code problem

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

with the following procedure entered into the sheet code of "Sheet1" the
method fails why?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Sheets("Sheet2").Select
Range("A1").Select
End Sub


I can enter the above code into a normal macro in a normal module then call
that sub fro the sheet code. but that seems daft, why doesn't it work
directly?



stuart
 
Because Range("A1").Select refers to the sheet containing the code, which
isn't the activesheet at that time

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Sheets("Sheet2").Select
Sheets("Sheet2").Range("A1").Select
End Sub
 
Back
Top