VBA automatically scroll down one row at a time ... using Wait function ?

palaeontology

Active Member
Joined
May 12, 2017
Messages
444
Office Version
  1. 2016
Platform
  1. Windows
I have a sheet with the top three rows frozen.

I have a command button (CommandButton2) which, when pressed, should start the sheet automatically scrolling downwards just one row every 3 seconds. So because the top three rows are frozen, I'd like row 4 to scroll up out of sight after 3 seconds, then row 5 to scroll up out of sight after a further 3 seconds, etc etc etc.

After the sheet has scrolled to row 40, I'd like the automatic scrolling to stop

This is what I've tried so far, but it is not working at all ...

VBA Code:
Private Sub CommandButton2_Click()
    For i = 4 To 40
    Range("a4").Select
    ActiveWindow.SmallScroll Down:=i
    Application.Wait (Now + TimeValue("00:00:03"))
    Next
End Sub

My vba is extremely poor, so it has taken me some time to get even to this stage. I apologise if it is embarrassingly incorrect.

Kindest regards,

Chris
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:

VBA Code:
Private Sub CommandButton2_Click()
  Dim i As Long
 
  Range("A4").Select                                'Outside the sentence For
 
  For i = 1 To 40
    Application.Wait (Now + TimeValue("00:00:03"))
    ActiveWindow.SmallScroll Down:=1                'must be 1
  Next
End Sub


If you want the visible cell in column A to remain selected, then:

VBA Code:
Private Sub CommandButton2_Click()
  Dim i As Long
   
  Range("A4").Select

  For i = 1 To 40
    Application.Wait (Now + TimeValue("00:00:03"))
    ActiveWindow.SmallScroll Down:=1                'must be 1
    Range("A" & i + 3).Select
  Next
End Sub

----- --
 
Last edited:
Upvote 0
Solution
Dante, thank you so much for putting that together.

Not only have you solved my problem, but my VBA will be all the better for it.

This was my first attempt at using 'i'.

Thankyou, again,

kindest regards,

Chris
 
Upvote 1

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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