On Wednesday, October 30, 2013 12:09:09 AM UTC+13, Mike wrote:
Hi
Been Trying to figure out how to declare a Variable for 2 Application On Time events in excel VBa
These events (Macro's) get called by another Macro then they have to wait for 10 - 20 minutes, when the time to run arrives they don't run.
Have read that "(EarliestTime argument) should be assigned to a variable to store it".
"(EarliestTime argument)" is in Cell $X$9 and $W$11 16:40:15 time format
Any help appreciated, Thanks
Sub settimers()
Application.OnTime TimeValue(Range("$X$9").Text), "StartBlink"
Application.OnTime TimeValue(Range("$W$11").Text), "StopBlink"
End Sub
Hi Walter
Thanks for assistance here is the paragraph that i interpreted as "Need to have Time to start, stored in a Variable"
As they run when called close to run time like a minute or so but any longer and they don't, i'm a stitch code together from the net type guy at the moment deffinately not schooled : )
These are the sentences i focused on, figured must be why they don't run, if variable needed for Canceling makes sense to me to have them for calling ?
Not trying to take it out of context just reducing read time for other.
--------------------------------------------
"if meanwhile another procedure is being executed and Excel is not in ready mode within 20 seconds, this procedure will not run."
"This means that the time when the procedure is to run (EarliestTime argument) should be assigned to a variable"
--------------------------------------------
Site where i got "need to send Earliest Time to a Variable"
http://www.globaliconnect.com/excel/...=79&Itemid=475
It says
--------------------------------------------------------
Stop or Cancel a Running Procedure (using the OnTime method)
To cancel a running procedure (using the OnTime method), the precise time of its scheduled run is required. Note that if you don't pass the time to a variable, Excel will not know which OnTime method to cancel, as Now + TimeValue("00:00:03") is not static, but becomes static when passed to a variable. This means that the time when the procedure is to run (EarliestTime argument) should be assigned to a variable (use a Public variable to make the variable available to all Procedures in all modules) and then use it to cancel the OnTime.
--------------------------------------------------------------------------
But still don't know what to do with what you have put i have 7 macro's to call actually in the same procedure but again reduced it to try and keep things simple for others who may help.
Any further clarification or actual running code appreciated
Thanks for response
Cheers