Scheduling a Macro to Run Every Two Minutes : Application OnTime « Application « VBA / Excel / Access / Word






Scheduling a Macro to Run Every Two Minutes

 
Sub ScheduleAnything()
    WaitHours = 0
    WaitMin = 2
    WaitSec = 0
    NameOfThisProcedure = "ScheduleAnything"
    NameOfScheduledProc = "RemindMe"
    NextTime = Time + TimeSerial(WaitHours, WaitMin, WaitSec)
    Application.OnTime EarliestTime:=NextTime, Procedure:=NameOfThisProcedure
    Application.Run NameOfScheduledProc
End Sub
Sub RemindMe()
    Application.Speech.Speak Text:="meeting."
End Sub

 








Related examples in the same category

1.Run on time
2.Set Refresh Data Timer
3.If you want to keep refreshing the data on a regular basis, you can make the macro run itself
4.Using Application.OnTime to Periodically Analyze Data
5.The OnTime event
6.Use OnTime to trigger the refresh data
7.writes the time to cell A1 and also programs another event five seconds later.