davewatson86
New Member
- Joined
- Jul 8, 2019
- Messages
- 30
Morning/Evening all
i have the below code set to update the data in a file every 5 min but it is running the Update sub twice one immediately after the other. i do not have the code (Application.OnTime mTimerTime, "my_Procedure") anywhere else in any other subs so im a bit stumped.
where am i going wrong?
thank you in advance
Dave
i have the below code set to update the data in a file every 5 min but it is running the Update sub twice one immediately after the other. i do not have the code (Application.OnTime mTimerTime, "my_Procedure") anywhere else in any other subs so im a bit stumped.
where am i going wrong?
Code:
Public Sub timer_on()
WS_Summary.Range("f21").Value = "On"
timer_off
my_Procedure
End Sub
Public Sub my_Procedure()
' Do timer work here
Call update
' Reset the timer
mTimerTime = Now() + TimeSerial(0, 5 - Minute(Now()) Mod 5 - 1, 60 - Second(Now()) Mod 60 + 1)
Application.OnTime mTimerTime, "my_Procedure"
End Sub
Public Sub timer_off()
On Error Resume Next
Application.OnTime mTimerTime, "my_Procedure", Schedule:=False
WS_Summary.Range("f21").Value = "Off"
On Error GoTo 0
End Sub
thank you in advance
Dave