Hi could someone please advise me on how to run modules at a certain time? the following images would show how my code is like thanks! I've tried running the modules seperately and they do work! so i think the issue is with the ontime function do let me know thanks.
Running modules at specific time using applicationontime
- xiaowang
- Thread is marked as Resolved.
-
-
-
Have a look here at something I wrote, to see how these things are structured
Run Codes On Timejiuk
Here is the code for reference
Code
Display MoreOption Explicit '// jiuk - Add this code In a the Worksheet "ThisWorkbook" Private Sub Workbook_Open() myCodes_To_RUN '// jiuk - any code you require can be added theEnd: '// jiuk do not Exit sub here End Sub '// jiuk - Add this code In a the Worksheet "Public "Module '// jiuk - This adds the scheduling times for the codes to run Sub myCodes_To_RUN() Select Case Time Case Is < TimeSerial(11, 0, 0) Application.OnTime TimeValue("11:00:00"), "ShowMessageMidday" Case Is < TimeSerial(12, 25, 0) Application.OnTime TimeValue("12:25:00"), "ShowMessage_afternoon" Case Is < TimeSerial(15, 25, 0) Application.OnTime TimeValue("15:25:00"), "ShowMessage_settle" Case Is < TimeSerial(18, 15, 0) Application.OnTime TimeValue("18:15:00"), "ShowMessage_EOD" End Select theEnd: '// jiuk do not Exit sub here End Sub '// jiuk - Add theses codes in a the Standard Module Sub ShowMessageMidday() MsgBox "Mid-day Statement run starts in an hour" theEnd: Exit Sub End Sub Sub ShowMessage_afternoon() MsgBox "Afternoon Recs in 30min" theEnd: Exit Sub End Sub Sub ShowMessage_settle() MsgBox "Review settlement starts in an hour" theEnd: Exit Sub End Sub Sub ShowMessage_EOD() MsgBox "EOD in starts in an hour" theEnd: Exit Sub End Sub
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!