ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   worksheets scrolling (https://www.excelbanter.com/excel-programming/420651-worksheets-scrolling.html)

Fan924

worksheets scrolling
 
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.

Jim Cone[_2_]

worksheets scrolling
 
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.

Mike H

worksheets scrolling
 
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

"Fan924" wrote:

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.



All times are GMT +1. The time now is 08:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com