worksheets scrolling

F

Fan924

Can two worksheets be synchronized so that they scroll together? If I
scroll down to line 500 on sheet1 and then switch to sheet2, it too
will be at line 500.
 
J

Jim Cone

Not exactly...
'Place this code in the module behind Sheet1.
'--
'Sheet1
Private Sub Worksheet_Deactivate()
On Error GoTo DoRight
If ActiveSheet.Name = "Sheet2" Then
Dim lngRowNum As Long
Application.EnableEvents = False
Me.Activate
lngRowNum = ActiveWindow.VisibleRange.Row
Sheets("Sheet2").Activate
ActiveWindow.ScrollRow = lngRowNum
Application.EnableEvents = True
End If
Exit Sub
DoRight:
Application.EnableEvents = True
End Sub
--
Jim Cone
Portland, Oregon USA



"Fan924"
wrote in message
Can two worksheets be synchronized so that they scroll together? If I
scroll down to line 500 on sheet1 and then switch to sheet2, it too
will be at line 500.
 
M

Mike H

Hi,

I'm sure there must be a way to get the ScrollRow property of an inactive
sheet and perhaps someone will tell us how. In the meantime try this:-

Alt +F11 to open VB editor, right click 'This Workbook' and insert module
and paste the colde below in.

Sub MySub()
Sheets("Sheet1").Select
ScrollTo = ActiveWindow.ScrollRow
Sheets("Sheet2").Select
ActiveWindow.ScrollRow = ScrollTo
End Sub

Then on the left side double click "Sheet2" and paste this code in

Private Sub Worksheet_Activate()
Application.EnableEvents = False
MySub
Application.EnableEvents = True
End Sub

Close VB editor and whenever sheet 2 is selected it will scroll to the same
row as sheet 1.

Mike
 
Top