Scrolling with stationary selection box??

G

glnflwrs

When you use the page-up and down keys, the selection box stays fixed and the
worksheet scrolls underneath it. When you scroll with the arrow keys the
selection box moves to the top or bottom and only then does the worksheet
scroll.

How can you make the selection box stay at mid screen while scrolling with
the arrow keys? This would give one the capability of seeing what is going to
come into view and to stop scrolling before passing what you're looking for.

Glenn.
 
G

Greg Wilson

Private Sub Workbook_Open()
Application.OnKey "{Up}", "ScrollUp"
Application.OnKey "{Down}", "ScrollDown"
End Sub

Private Sub ScrollUp()
Dim Rw As Long, RwTop As Long
If ActiveCell.Row > 1 Then ActiveCell(0).Select
With ActiveWindow
RwTop = .VisibleRange(1).Row
Rw = RwTop + .VisibleRange.Rows.Count / 2
If ActiveCell.Row < Rw Then _
.ScrollRow = Application.Max(.ScrollRow - 1, 1)
End With
End Sub

Private Sub ScrollDown()
Dim Rw As Long, RwTop As Long
If ActiveCell.Row < Rows.Count Then ActiveCell(2).Select
With ActiveWindow
RwTop = .VisibleRange(1).Row
Rw = RwTop + .VisibleRange.Rows.Count / 2
If ActiveCell.Row > Rw Then _
.ScrollRow = Application.Min(.ScrollRow + 1,
Rows.Count)
End With
End Sub

Regards,
Greg
 
G

glnflwrs

Greg,
Is that a macro, a script file? I'm a newbie at Excel but I'm good at
figuring things out if pointed in the right direction.
Glenn
 
G

glnflwrs

Never mind, I've located and am using the VB Editor now. Thanks alot for your
time.
Glenn ;>)
 

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