Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50110

[SOLVED] Application.OnTime VBA

$
0
0
What I want is to make it simple, I think.
Using Application.OnTime VBA, I want to put (with a button) an "Yes" (only once) in a particular cell. To keep this "Yes" for 5 seconds, then to be removed.
I tried to modify but the result obtained is not what I want.
This is VBA what I think can do that.

Code:

Sub MacroAutoRun()
'Macro should be entered in a Standard Module (select Insert>Module, in code window).
Dim rTime As Date
rTime = Now + TimeValue("00:00:05")

Application.OnTime EarliestTime:=rTime, Procedure:="MacroAutoRun", schedule:=True

'Modify but the result obtained is not what I want.
Cells(1, 1).Value =  "YES"

If Cells(1, 1).Value > 1 Then
Cells(1, 1).Value = ""

End If

End Sub

Your opinions are welcome.
Thank you.

Viewing all articles
Browse latest Browse all 50110

Trending Articles