Use the OnTime method to run a VBA procedure on a particular day: runs the DisplayAlarm procedure at 5:00 p.m. on December 31, 2007: : DateValue « Date Functions « VBA / Excel / Access / Word






Use the OnTime method to run a VBA procedure on a particular day: runs the DisplayAlarm procedure at 5:00 p.m. on December 31, 2007:

 
Sub Main()
Application.OnTime DateValue("12/31/2007 5:00 pm"), "DisplayAlarm"
End Sub
Sub DisplayAlarm()
    Beep
    MsgBox "Wake up. It's time for your afternoon break!"
End Sub

 








Related examples in the same category

1.DateValue(date) returns a Variant/Date containing the specified date
2.DateValue("Nov, 23 04") returns 11/23/2004