A Macro For Continuous Screen Scrolling?

alanalnr

New Member
Joined
May 4, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Mr. Excel, ?

I have a large list of dart tournament contestant names displaying the opponents and the board the match will be played upon. If I zoom the entire list on the monitor, people can't read the small text. Is there a formula or a macro that will slowly scroll down the list? Ultimately, I would like to press a button and have the screen slowly scroll down to the bottom of the list and then scroll back up to the top of the worksheet continuously until I press the button again. Can the scroll speed be varied? I have skimmed through several VBA reference manuals and this issue is not addressed.

An example of the continuous scrolling would be pressing down on a mouse with a wheel.

I found a macro in the forum that Mr. Kenneth Hobson replied to in a topic, and set a time for those lines with the code "" Application.Wait (Now + TimeValue ("0:00:01")) ", but no I'm managing to make the macro read a certain number of lines and go back to the beginning, for example: Start reading on A5 and finish on A15 and return to A5.

VBA Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public inc As Integer

Sub ScrollNow()
  Dim lastRow As Long, nextRow As Long
  Application.ScreenUpdating = True
  
  lastRow = ActiveSheet.UsedRange.Rows.Count
  If inc <> 1 Or inc <> -1 Then
    If ActiveCell.Row = lastRow Then
      inc = -1
      Else: inc = 1
    End If
  End If
  
  On Error GoTo handleCancel
  Application.EnableCancelKey = xlErrorHandler
  
  Application.StatusBar = "To End: ESC, Ctrl+Break"
  Do While 1 = 1 'infinite loop
    If inc = 1 And lastRow = ActiveCell.Row Then inc = -1
    If inc = -1 And ActiveCell.Row = 1 Then inc = 1
    nextRow = ActiveCell.Row + inc
    Application.Goto Range("A" & nextRow), True
    Sleep 400
    Application.Wait (Now + TimeValue("0:00:01"))
    'Return to the top

End Sub
  Loop
handleCancel:
  Application.StatusBar = False
End Sub


Thanks for your time!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
the correct macro is
VBA Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public inc As Integer

Sub ScrollNow()
  Dim lastRow As Long, nextRow As Long
  Application.ScreenUpdating = True
  
  lastRow = ActiveSheet.UsedRange.Rows.Count
  If inc <> 1 Or inc <> -1 Then
    If ActiveCell.Row = lastRow Then
      inc = -1
      Else: inc = 1
    End If
  End If
  
  On Error GoTo handleCancel
  Application.EnableCancelKey = xlErrorHandler
  
  Application.StatusBar = "To End: ESC, Ctrl+Break"
  Do While 1 = 1 'infinite loop
    If inc = 1 And lastRow = ActiveCell.Row Then inc = -1
    If inc = -1 And ActiveCell.Row = 1 Then inc = 1
    nextRow = ActiveCell.Row + inc
    Application.Goto Range("A" & nextRow), True
    Sleep 400
    Application.Wait (Now + TimeValue("0:00:01"))
  Loop
handleCancel:
  Application.StatusBar = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

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