Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In message of
Tue, 29 Oct 2013 04:09:09 in microsoft.public.excel.programming, Mike writes 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 I have the following code, which works with Excel 2003. Sub somename() .... Dim IEalarm As Date ' Date at which MakeIEVisible will run .... IEalarm = Now + TimeValue("00:00:15") Application.OnTime EarliestTime:=IEalarm, Procedu="MakeIEVisible" .... end sub You would need 2 variables for your 2 timers. Where did you read "(EarliestTime argument) should be assigned to a variable to store it"? The 2003 help for ontime has several examples which suggest otherwise, including Application.OnTime EarliestTime:=TimeValue("17:00:00"), _ Procedu="my_Procedure", Schedule:=False Have you tried running your code? I see no reason why it should not work. -- Walter Briscoe |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 Mike |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In message of
Tue, 29 Oct 2013 14:28:23 in microsoft.public.excel.programming, Mike writes 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/...content&view=a rticle&id=103:applicationontime-vba-schedule-excel-to-run-macros-at- periodic-intervals-or-a-specified-time&catid=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 Mike I am pleased with the answer to my question. <http://www.globaliconnect. com looks useful. I agree that you need a variable to cancel a timer, whose value is not static. From what I see, your timers ARE static. Assuming the story is more complicated than you have said, I suggest you extend the examples on that page with something like these untested fragments. Const TimerCount as Long = 7 Dim Timers(1:TimerCount) as Date Timers(1) = ... .... Timers(TimerCount) = ... Application.Ontime Timers(1), "Sub1" .... Application.Ontime Timers(TimerCount), "SubTimerCount" You will probably need some logic to note if each timer is active. e.g. sub sub1() Timers(1) = 0 ... end sub Then you need code to conditionally cancel timers. if Timers(1) < 0 Application.Ontime Timers(1), "Sub1", , False .... if Timers(TimerCount) < 0 Application.Ontime Timers(TimerCount), _ "SubTimerCount", , False VBA does not seem to support arrays of functions. ;( -- Walter Briscoe |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Walter I actually think EarliestTime macro's run intermittently, (unpredictable times) could be not due to a lack of a Variable to store time format in Linked Cell but because i have the time ticking over in 3 second intervals, to help Excel calculate as there is so much being calculated, not the most upto date computer, so have set it back to 1 second, i thought everything ran off system time, test again tomorrow just incase someone reading this is having issues to, beginners ay : ) Cheers |
#7
![]() |
|||
|
|||
![]() Quote:
Works when i manually click button to tell Application on times to look out for times in there appropriate cells but when called by another macro (Clicked) Omg no good . Stiil had no real help with setting up working variables so maybe times get stored, looks like i have to save all my pennies and ask a professional, hate that. http://www.mrexcel.com/forum/excel-q...lications.html |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to set up a simple variable in Excel, but cell location independent | Excel Worksheet Functions | |||
VBA Formula with variable s/b simple | Excel Programming | |||
variable cell referencing for simple data points | Excel Programming | |||
Simple Variable Question | Excel Programming | |||
Simple problem refering to variable in For ... Next loop ... | Excel Programming |