Macro to page down every 5 minutes?

Hydra427

New Member
Joined
Jan 17, 2017
Messages
3
Can someone help me with the code to automatically page down every 5 minutes until the last record is reached and then return to the top and start over. I have a spreadsheet that automatically updates (refreshes) every 15 minutes and want it to automatically page down every 5 minutes so that the shop can see the latest inventory to pull.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
All right, I have figured out how to page down every :30 but need to to repeat the page down until it reaches the last record and then return to the first record and continue. This must also work as the spreadsheet automatically refreshes every 15 minutes. Here is the code I am using to page down.

Sub Macro1()
'
' Macro1 Macro
'
'
Range("A1").Select
Application.Wait (Now + TimeValue("0:00:30"))
ActiveWindow.LargeScroll Down:=1


End Sub
 
Upvote 0
Try this code in a standard module. It looks in column A to determine the last row, so change the "A" in the code to use a different column.

Code:
Option Explicit

Public RunWhen As Double

Public Sub StartTimer()
    RunWhen = Now + TimeValue("00:00:30")
    Application.OnTime EarliestTime:=RunWhen, Procedure:="Page_Down", Schedule:=True
End Sub

Public Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:="Page_Down", Schedule:=False
End Sub

Public Sub Page_Down()

    Dim lastRow As Long
    
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row
    ActiveWindow.LargeScroll Down:=1
    If ActiveWindow.ScrollRow > lastRow Then ActiveWindow.ScrollRow = 1
    
    StartTimer
        
End Sub
Run or call StopTimer to stop the scrolling (e.g. from a command button), and put this code in the ThisWorkbook module to stop the timer when you close the workbook:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    StopTimer
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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