Synchronize sheets by row?

J

jrcruzr

I'm using Excel 2002. Is there a way to toggle between 2 sheets pointing on
the same row number? Example: Sheet1 R1C1, when I select Sheet2 cursor points
to the same address R1C1.

Thanks in advance,
 
R

Rick Rothstein

You should be able to use this worksheet event code...

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet1" Or Sh.Name = "Sheet2" Then Sh.Range("A1").Select
End Sub

Note: I don't have XL2002, rather I have XL2003; but I think the above
should work for either version.
 
P

Per Jessen

If you want to take the cursor to current row when you change sheet then you
need this:

Declare the variable in an ordinary module :
Public ActiveRow As Long

Place this in the codesheet for Sheet1 and Sheet2:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveRow = ActiveCell.Row
End Sub

Place this in the codesheet for ThisWorkbook:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "Sheet1" Or Sh.Name = "Sheet2" Then
Cells(ActiveRow, 1).Select
End If
End Sub
 
C

Chip Pearson

Open the ThisWorkbook module and enter the following code:

Private LastAddr As String

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
Sh.Range(LastAddr).Select
End Sub

Private Sub Workbook_SheetSelectionChange( _
ByVal Sh As Object, ByVal Target As Range)
LastAddr = Target.Address
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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