Application.Ontime not completing loop

D_Theroux

New Member
Joined
Jun 1, 2015
Messages
2
Hello Everyone,

Fresh set of eyes needed for this problem. VBA code works fine when in break mode but not in execution mode

Sub Scheduler()

Dim runtimer As Double
runtimer = Now + TimeSerial(0, 45, 0)

If Hour(Now) > 16 Then
<Do stuff>
Else
Application.OnTime runtimer, "Macro1", schedule:=True
End If

End Sub
Sub Macro1()

<Do stuff>
DoEvents

Worksheets(2).Range("A2").End(xlDown).Offset(1, 0).Value = Now() 'Meant to be proof of completion in a Log table
Call Scheduler

End Sub

All the "stuff" in Macro1 gets done however it seems to fall apart after (i.e. Now doesn't get added to the log chart and Scheduler Macro doesn't get called again.

Thank you in advance
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How do you determine that "Macro1" don't get scheduled? Do you normally work having more than one single workbook open? Can you show the code for "do stuff"? Please also tell us the name of the Vba Module that host the code (as you read it into the header of the window whose name says "Microsoft Visual Basic, Application Edition - XYZ Etc Etc"

Bye
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top