View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Have something occur on scroll

to answer your first question:

Dim lngFirstRowBeingDisplayed As Long
Dim lngLastRowBeingDisplayed As Long

With ActiveWindow.VisibleRange
lngFirstRowBeingDisplayed = .Rows(1).Row
lngLastRowBeingDisplayed = .Rows(.Rows.Count).Row
End With

MsgBox lngFirstRowBeingDisplayed & ":" & lngLastRowBeingDisplayed

Don't know about the second. XL does not have a scroll event for
worksheets. Depending on what you need the first and last rows for - perhaps
one of the built in worksheet event handlers would be equally suitable.


"GeorgeJ" wrote:

Suppose I have a worksheet active. At any given time, a certain set of rows
on the sheet are being displayed.

1) How would I have a VBA put the correct values in the variables
FirstRowBeingDisplayed as Long
LastRowBeingDisplayed as Long

2) The program terminates and the user is now in the direct mode. He is
free to move around in the worksheet. How might I set it up so that if his
moving around (with the arrow keys, mouse, or scroll bar, or whatever)
trggers a scrolling event, a subroutine Scroll_Routine is executed. )By
scrolling event I means an event which changes the set of cells displayed).
The first thing I want Scroll_Routine to do is to assign the correct values
to the variables FirstRowBeingDisplayed, LastRowBeingDisplayed,
FirstColBeingDisplayed, LastColBeingDisplayed.

Thank you




--
-regards