Scheduling a Macro to Run x Minutes in the Future : TimeSerial « Date Functions « VBA / Excel / Access / Word






Scheduling a Macro to Run x Minutes in the Future

 
Sub ScheduleAnything()
    WaitHours = 0
    WaitMin = 2
    WaitSec = 30
    NameOfScheduledProc = "CaptureData"
    NextTime = time + TimeSerial(WaitHours, WaitMin, WaitSec)
    Application.OnTime EarliestTime:=NextTime, Procedure:=NameOfScheduledProc
End Sub

 








Related examples in the same category

1.TimeSerial(hour, minute, second) returns a Variant/Date containing the time for the specified hour, minute, and second
2.TimeSerial(9, 0, 0) returns 9:00:00 AM