• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Application.OnTime macro not working

ThrottleWorks

Excel Ninja
Hi,

I am trying to replicate (relatively simple) code mentioned below.
However this macro is not getting fired at all !

Code:
Private Sub Workbook_Open()
'Run YourSub at 6pm
Application.OnTime TimeValue("14:08:00"), "Test"
End Sub

Sub Test()
MsgBox "Hello !"
End Sub
Can anyone please help me regarding what I am missing here.
 
Last edited by a moderator:
Hi Deepak,

Thanks for your help once again ! I am not sure why it is not working on my PC. :(

Seems to pretty simple, don't know why it's not working.
 
Hi Deepak,

I need to run the macro at specific time(s) of the day.
That is why I am looking for application.ontime.

Thanks for the help. Have a nice weekend. :)
 
Hi,

Change this & check!!

Code:
Private Sub Workbook_Open()

Dim mytime As Double, r As Double

mytime = TimeValue("18:53:50") 'run time

r = mytime - Time

If r > 0 Then Application.OnTime Now + r, "Test"

End Sub
 
@Deepak , it's not working either. I will do one thing. I will check both the codes at home and will revert.

May be I have system issues here.

Have a nice day ahead.

PS - I have bought a new PC today itself. :P
 
Hi Sachin ,

Please remember that the Workbook_Open procedure needs to reside in the
ThisWorkbook section of the project. However , because the call to Test has not been qualified , the Test procedure needs to reside in a module.

Narayan
 
Hi @NARAYANK991 Sir, thanks for the help.

I guess I have done the same thing as advised by you.

But do not understand why it's not working.

Have a nice day ahead. :)
 

Attachments

  • S1.png
    S1.png
    18 KB · Views: 7
  • S2.png
    S2.png
    12.4 KB · Views: 5
Hi Sachin ,

There are only two possibilities viz. that macros are not enabled , or the PC clock is not correctly set.

To test this , see if you can run the Workbook_Open procedure manually , by placing the cursor anywhere within the procedure and pressing F5. It should run and thereafter , the Test procedure should also run.

It is now after 3:15 pm , and you can change the time within the Workbook_Open procedure to some time within a few minutes from when ever you check it ; wait for some time and see if the Test procedure runs and displays the message.

If not , check the PC clock to see whether it is what it should be.

Narayan
 
@ narayan Sir, I have checked it (on Friday itself) even I change the time to 1-2 minutes later and pressed F5 but it's not working.

I will check the same code at my home PC may be that will give us idea if the issue is code writing (by me) or it's system issue.

Thanks for the help. :)
 
Back
Top