Schedule Macro doesn't seem to run any suggestions

J

jk9533

Below is a scheduled macro to run everyday at 5:00 am. It doesn't seem to be
working. Does anybody know how to fix?

Sub Schedule()
Application.OnTime EarliestTime:=TimeValue("5:00 AM"),
Procedure:="RefreshDaily", Schedule:=True
End Sub

Thanks
 
G

garys_student

Below is a scheduled macro to run everyday at 5:00 am.  It doesn't seemto be
working.  Does anybody know how to fix?

Sub Schedule()
    Application.OnTime EarliestTime:=TimeValue("5:00 AM"),
Procedure:="RefreshDaily", Schedule:=True
End Sub

Thanks

You need the date as well as the time:
Application.OnTime EarliestTime:=Date + TimeSerial(5, 0, 0) + 1
will schedule the next run tomorrow

gsnu2007k
 
G

garys_student

If you include the line in RefreshDaily, It schedules the next entry
for tomorrow.

So the +1 is necessary!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Run time error 2
On time kill 4
OnTime VB 5
Cancel Ontime routine 3
Simple Variable to someone 5
Timer event 2
Workbook-Close StopTimer event 2
If statements in macros 10

Top