Create a scrolling macro

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,237
Office Version
  1. 2016
Platform
  1. Windows
On my spreadsheet, I have cell C23542 highlighted as the activecell. I'm going to be reading down to row C23635 (or could be another range within column C). As I'm reading the text, I would like the screen to scroll until it hits the last cell, but with this code, the activecell never changes during the scroll, so I don't know how to exit as I reach the last cell. How can I achieve this scrolling?

VBA Code:
Sub CreateScrollDown()

    Dim lastrow As Long: lastrow = Range("A" & Rows.Count).End(xlUp).Row
    Dim StopPoint As Long: StopPoint = Range("MyEnd")
    
    While Intersect(Rows(lastrow), ActiveWindow.VisibleRange) Is Nothing
        Application.Wait (Now + TimeValue("0:00:01"))
        ActiveWindow.SmallScroll down:=Round(ActiveWindow.VisibleRange.Rows.Count / 5, 0)
    Wend
    Application.Wait (Now + TimeValue("0:00:03"))
    ActiveWindow.ScrollRow = 1
        
End Sub
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
1,295
Office Version
  1. 2013
Platform
  1. Windows
How about
VBA Code:
Sub CreateScrollDown()

    Dim LastRow As Long, CurrRow As Long, r As Range
    
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    
    With ActiveWindow
        Do
            Set r = .VisibleRange
            CurrRow = r.Rows(r.Rows.Count).Row
            Application.Wait (Now + TimeValue("0:00:01"))
            .SmallScroll down:=Round(r.Rows.Count / 5, 0)
            
        Loop While CurrRow < LastRow
        
        Application.Wait (Now + TimeValue("0:00:03"))
        .ScrollRow = 1
    End With
End Sub
 
Solution

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,237
Office Version
  1. 2016
Platform
  1. Windows
Yes, that is perfect and will work for my needs. Thank you.
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
1,295
Office Version
  1. 2013
Platform
  1. Windows
You are welcome and thanks for letting me know.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,831
Messages
5,627,149
Members
416,223
Latest member
RichardHell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top