ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Schedule Macro doesn't seem to run any suggestions (https://www.excelbanter.com/excel-discussion-misc-queries/214596-schedule-macro-doesnt-seem-run-any-suggestions.html)

jk9533

Schedule Macro doesn't seem to run any suggestions
 
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"),
Procedu="RefreshDaily", Schedule:=True
End Sub

Thanks


[email protected]

Schedule Macro doesn't seem to run any suggestions
 
On Dec 24, 11:10*am, jk9533 wrote:
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"),
Procedu="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

jk9533

Schedule Macro doesn't seem to run any suggestions
 
To have it run everyday do I still need the "+1"

" wrote:

On Dec 24, 11:10 am, jk9533 wrote:
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"),
Procedu="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


[email protected]

Schedule Macro doesn't seem to run any suggestions
 
If you include the line in RefreshDaily, It schedules the next entry
for tomorrow.

So the +1 is necessary!


All times are GMT +1. The time now is 02:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com