Could someone please help me how to stop the OnTime Function? It doesnt work the way I tried it.
Option Explicit
Dim iTimerSet As Double
Public Sub FXKurs_Wahl()
iTimerSet = Now + TimeValue("00:05:00")
Application.OnTime iTimerSet, "FXKurs_Wahl"
End Sub
Public Sub EndeUhr()
On Error Resume Next
Application.OnTime iTimerSet, "FXKurs_Wahl", , False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call EndeUhr
End Sub
Thank you!
As stated in the documentation of the Application.OnTime method
Syntax is
.OnTime(EarliestTime, Procedure, LatestTime, Schedule)So if you used
to start it you need to use
to stop it. Note that
iTimerSetneeds to be the same value for both.Make sure that if you run
FXKurs_Wahlmultiple times you would need to delete multipleOnTimeprocedures. Also make sure there is no other code manupulating theiTimerSetvalue.If it can occur to run
FXKurs_Wahlmultiple times try removing the old one before adding a newOnTime