ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Capture scrolling event (https://www.excelbanter.com/excel-programming/295862-capture-scrolling-event.html)

Allen[_12_]

Capture scrolling event
 
I want to compare two or more worksheets or charts. When
they are display the on screen, I'd like to be able scroll
in one active sheet and have the other sheet windows
scrolling synchronistically. The problem is there is no
worksheet/workbook/application event for capturing this
scrolling action.

Can anybody help with some ideas?


TroyW[_2_]

Capture scrolling event
 
Allen,

Interesting question. I use a program called TextPad for editing text files
and it has a similar feature where you can scroll two files side-by-side.
Very useful for debugging ASP and HTML code files.

In Excel, there isn't a Scrolling event but here is an example of how to
coordinate ActiveCell movements by using the Worksheet_ SelectionChange
event. Place the code in the Sheet code pane (not a standard Module code
pane) of the worksheet that is the master or driver. I hard coded the
workbooks as 1 and 2. You may need to change this for your situation. In
this example, Workbooks(1) drives Workbooks(2).

As you probably know, you can use the Window | Arrange... (Vertical) command
from the menubar to tile the two workbooks next to each other.

'''====== This code works for two workbooks.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sRng As String
Dim lngTLRow As Long
Dim lngTLCol As Long

sRng = Target.Address
lngTLRow = ActiveWindow.ScrollRow
lngTLCol = ActiveWindow.ScrollColumn

Application.ScreenUpdating = False
With Workbooks(2)
.Activate
ActiveWindow.ScrollRow = lngTLRow
ActiveWindow.ScrollColumn = lngTLCol
.ActiveSheet.Range(sRng).Select
End With
Workbooks(1).Activate
Application.ScreenUpdating = True
End Sub

================================================== ==================

For the situation where you want to compare two worksheets in a single
workbook. Use the Window | New Window command to create a second window of
the single workbook. Then use the Window | Arrange command to tile the
windows vertically. Select the second sheet in the second window. Place the
code below in the worksheet code pane that is the driver. You may need to
switch the 1 and 2 indexes or use a name in the Window objects below for
your situation. Be careful, I think I saw the second window created is
indexed as Windows(1) and the original window is Windows(2).

'''====== This code works for two sheets in the same workbook in two window
panes.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sRng As String
Dim lngTLRow As Long
Dim lngTLCol As Long

sRng = Target.Address
lngTLRow = ActiveWindow.ScrollRow
lngTLCol = ActiveWindow.ScrollColumn

Application.ScreenUpdating = False
With ActiveWorkbook.Windows(2)
.Activate
ActiveWindow.ScrollRow = lngTLRow
ActiveWindow.ScrollColumn = lngTLCol
.ActiveSheet.Range(sRng).Select
End With
ActiveWorkbook.Windows(1).Activate
Application.ScreenUpdating = True
End Sub


Hopefully this gets you started.

Troy


"Allen" wrote in message
...
I want to compare two or more worksheets or charts. When
they are display the on screen, I'd like to be able scroll
in one active sheet and have the other sheet windows
scrolling synchronistically. The problem is there is no
worksheet/workbook/application event for capturing this
scrolling action.

Can anybody help with some ideas?




Dave Peterson[_3_]

Capture scrolling event
 
Jim Rech posted this:

http://groups.google.com/groups?selm...%40cppssbbsa03

It may do what you want (well, if you change it to Trues).

And I think that I've seen posts that this is built into xl2003. (but not sure)

Allen wrote:

I want to compare two or more worksheets or charts. When
they are display the on screen, I'd like to be able scroll
in one active sheet and have the other sheet windows
scrolling synchronistically. The problem is there is no
worksheet/workbook/application event for capturing this
scrolling action.

Can anybody help with some ideas?


--

Dave Peterson



All times are GMT +1. The time now is 11:51 PM.

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