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
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,970
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,295
Messages
5,595,294
Members
413,984
Latest member
stikpet

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
Top