Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Running of a Script?
I have a script that I'd like to run randomly between X and Y minutes.
Is there a way to make a small function to call that function randomly in that time frame? Ideally I could also push yet another random # into it. Thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Running of a Script?
Hi,
There are several ways of initiating this, here's one. assuming your 'script' is called MySub then to gererate the random number of minutes we use the formula x=Int((upperbound - lowerbound + 1) * Rnd + lowerbound) where you substitute upperbound and lowerbound with the upper and lower minutes. So the code looks like this and when run once it will recursively call itself every x minutes. Sub MySub() 'Your Code x = Int((10 - 1 + 1) * Rnd + 1) Application.OnTime Now + TimeValue("00:" & x & " :00"), "MySub" End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "msnyc07" wrote: I have a script that I'd like to run randomly between X and Y minutes. Is there a way to make a small function to call that function randomly in that time frame? Ideally I could also push yet another random # into it. Thanks in advance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Running of a Script?
Many thanks!
"Mike H" wrote: Hi, There are several ways of initiating this, here's one. assuming your 'script' is called MySub then to gererate the random number of minutes we use the formula x=Int((upperbound - lowerbound + 1) * Rnd + lowerbound) where you substitute upperbound and lowerbound with the upper and lower minutes. So the code looks like this and when run once it will recursively call itself every x minutes. Sub MySub() 'Your Code x = Int((10 - 1 + 1) * Rnd + 1) Application.OnTime Now + TimeValue("00:" & x & " :00"), "MySub" End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "msnyc07" wrote: I have a script that I'd like to run randomly between X and Y minutes. Is there a way to make a small function to call that function randomly in that time frame? Ideally I could also push yet another random # into it. Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problems running a dos program from vba script | Excel Programming | |||
Running a script while editing a cell | Excel Discussion (Misc queries) | |||
Running a Script upon Saving a File | Excel Programming | |||
running vbs script from vba? | Excel Programming | |||
Running a VB Script | Excel Programming |