Open worksheet at specific cell

R

rob

I have code to open a workbook at a specific worksheet. This works great! I
still want to be able to do this along with being able to open any other
worksheet at a specific cell. In other words, I want to click on a worksheet
and have cell A242 be in the upper left corner. Does anyone have code to
accomplish this?

rob
 
G

Gord Dibben

Rob

Private Sub Worksheet_Activate()
Application.Goto Reference:="StartPoint", Scroll:=True
End Sub

Name A242 as startpoint.

Copy/paste the code to your worksheet module.


Gord Dibben MS Excel MVP
 
R

rob

Gord,
Thanks for the help, but the code you gave me didn't work. It comes back as
"Run-time error '1004'. I pasted it in as worksheet code and replaced
StartPoint with A242, got same message. Tried different ways for reference
and got same message, not a valid reference. The cell is empty, does that
make a difference?
 
G

Gord Dibben

Rob

StartPoint is a named range created by going to Insert>Name>Define>Add>Type in
StartPoint

In the refers to box enter =Sheet1!A242 where Sheet1 is the name of your sheet.

Close and try again.


Gord
 
R

rob

Gord,
Thanks, it works great!

Rob

Gord Dibben said:
Rob

StartPoint is a named range created by going to Insert>Name>Define>Add>Type in
StartPoint

In the refers to box enter =Sheet1!A242 where Sheet1 is the name of your sheet.

Close and try again.


Gord
 
G

Gord Dibben

Thanks for the feedback and apologies.

Would have saved you some time and effort if I had explained the part about
Insert>Name>Define first time around.


Gord
 
Top