Hi
I have written a macro that runs at 15:30pm every workday when a workbook is first opened. When the workbook is closed it tries to open itself the next time the macro is scheduled to run. I have tried to turn the scheduler to false and am getting an error. Code below. Has anyone any ideas why this isn't working?
Thanks
Private Sub Workbook_Open()
Application.OnTime TimeValue("15:30:00"), "MacroTimeTest"
End Sub
public dtime as date
Sub MacroTimeTest()
dtime = (Format(Application.Evaluate("workday(today(), 1)"), "DD/MM/YY") & " " & TimeValue("15:30:00"))
'other code has been deleted doesn't affect dtime variable
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'I have tried replacing false with 0 etc but it didn't make a difference
Application.OnTime earliesttime:=dtime, procedure:="MacroTimeTest", schedule:=False
End Sub