Hello all,
I'm trying to run macro every x seconds when the Toggle Button is pressed in. When it's unpressed the macro should stop running. But unfortunately when you unpres the button the macro keeps running. This is what i have come up with so far:
Button code:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
Call update_send
Else
Call stopSaveTimer
End If
End Sub
Macro:
Public saveTime As Double ' I avoid type Date
Sub update_send()
Call update_data
Call send_updates
Call startSaveTimer
End Sub
Sub startSaveTimer()
whenTime = Now + TimeValue("00:00:15") ' I prefer TimeSerial(0,10,0)
Application.OnTime whenTime, "update_send"
End Sub
Sub stopSaveTimer()
On Error Resume Next
Application.OnTime whenTime, "update_send", , False
End Sub
Bookmarks