• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Stop An OnTimeMacro From Running

I am looking to run a timer in a sub every 3 seconds, and to stop the timer when the sub is done. I just can't figure out the turn it off part.


Sub OnTimeMacro()

Application.OnTime Now + TimeValue("00:00:03"), "myMacro"

End Sub


mySUB()

Call myMacro

'yada yada other stuff

Exit OnTimeMacro

End Sub
 
what about adding a small If

[pre]
Code:
Sub OnTimeMacro()
If Worksheets(worksheet).Range(a cell).value = Some_value 'Change values to suit
Application.OnTime Now + TimeValue("00:00:03"), "myMacro"
End If
End Sub
[/pre]
 
That worked!


I used the value as a tab sheet name.


If Worksheets(1).Name = "Removing Special Characters" Then

Application.OnTime Now + TimeValue("00:00:03"), "myMacro"

Else

Worksheets(1).Name = "Special Characters Removed"

End If
 
Back
Top