scrolling up & down - ajit

G

Guest

I have arranged news.xls with two vertical windows i.e. news1 &
news2. I am comparing two different sheets of the same file. But
unlike Lotus, I can not see two rows simultaneously i.e. if I scroll
up in sheet1, the same row no. of sheet2 does not scroll up. Thus
after one screenful of sheet1, I have to scroll up one screenful of
sheet2. Is there any way out to this problem?
ajit
 
D

Dave Peterson

This was added as a built-in feature in xl2003.
(With two windows open, Window|Compare side by side)

This kind of macro worked for me in xl2003 if both windows were showing the same
worksheet:

Option Explicit
Sub SyncWindows()
Windows.Arrange ActiveWorkbook:=True, _
synchorizontal:=True, syncvertical:=True
End Sub

But I don't recall how/if it worked in earlier versions of excel.

This seemed to mimic the syncing (if you changed selection--not just scrolled).

This is a workbook event and goes behind the ThisWorkbook module.

Rightclick on the excel icon (to the left of the File option on the worksheet
menu bar).

Select view code and paste that code into the code window.

Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)

Dim myWindow As Window
Dim myMstrWindow As Window

If Me.Windows.Count < 2 Then Exit Sub

Set myMstrWindow = ActiveWindow

With Application
.EnableEvents = False
.ScreenUpdating = False
End With
For Each myWindow In Me.Windows
If myWindow.Caption = myMstrWindow.Caption Then
'do nothing
Else
myWindow.ScrollColumn = myMstrWindow.ScrollColumn
myWindow.ScrollRow = myMstrWindow.ScrollRow
myWindow.Activate
ActiveSheet.Range(Target.Address).Select
End If
Next myWindow

myMstrWindow.Activate

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm
 

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