VBA assistance needed

Status
Not open for further replies.

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
708
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
I have this code that scrolls down the page.
It starts at B8 but doesn't stop.

How do I make it stop at row 158 then start over from the top.
It will loop until {ESC} is pressed.
Thanks, PuJo
Code:
Sub SlowScroll()
    Application.EnableCancelKey = xlErrorHandler
    On Error GoTo ErrHandler

    Dim r As Long
    Range("B8").Select
    Do
        DoEvents
        Sleep 2000
        ActiveWindow.SmallScroll Down:=5
        r = r + 1
        If r = 50 Then Range("B8").Select: r = 0
       
    Loop

    Application.EnableCancelKey = xlInterrupt
    Exit Sub

ErrHandler:
    Application.EnableCancelKey = xlInterrupt
    ActiveWindow.ScrollRow = 1
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Let me correct myself...
Do Until first empty cell then start over from the top...
Thanks!
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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
Back
Top