Fire vba when time hits ....

Please post any questions regarding the program here.

Moderator: 2020vision

Fire vba when time hits ....

Postby mikedmc » Tue Oct 14, 2008 9:26 pm

Hi,

I would appreciate a little help with my vba. Currently I have been able to have the appropriate vba fire when required but due to refresh times or when I have more than 1 mkt being watched the timer sometimes misses the time required therefore the vba isn't fired. This is my current vba.

Code: Select all
If Target.Columns.Count <> 16 Then Exit Sub
Application.EnableEvents = False

Select Case Worksheets("Mkt3").Range("D12").Value

           Case TimeValue("00:15:00")
              Worksheets("Mkt3").Range("AC15:AC60").Value = ""
              Worksheets("Mkt3").Range("AE15:AE60").Value = ""
              Worksheets("Mkt3").Range("AC15:AC60").Value = Worksheets("Mkt3").Range("AA15:AA60").Value
             
          Case TimeValue("00:02:00")

              Worksheets("Mkt3").Range("AE15:AE60").Value = Worksheets("Mkt3").Range("AA15:AA60").Value

    End Select

Application.EnableEvents = True


Works fine except when it misses the time (D12 is by the way is D2 if u start in A1). Is there an easy way to have this fire at the above times without it ever missing the time or have a little leway put in that will allow for the odd miss?

I was thinking of having it fire between 2 times e.g. for the 00:15:00, have it fire between 00:15:00 and 00:14:55 but then it continues 2 fire until it reaches 00:14:55, I would prefer it 2 fire just the once.

Any suggestions, tips, advice as always appreciated. Thank you.
mikedmc
 
Posts: 79
Joined: Wed May 14, 2008 7:47 pm
Location: London

Re: Fire vba when time hits ....

Postby alrodopial » Wed Oct 15, 2008 5:47 am

mikedmc wrote:I was thinking of having it fire between 2 times e.g. for the 00:15:00, have it fire between 00:15:00 and 00:14:55 but then it continues 2 fire until it reaches 00:14:55, I would prefer it 2 fire just the once.

Any suggestions, tips, advice as always appreciated. Thank you.


Inside the VBA and after the point you want place something like this:
Range("AA1")="DONE"
so you create a flag that tells you that your macro has been fired.
Combine it with something like this : If Range("AA1")="DONE" then Exit Sub.

Before next race you have to clear the AA1.
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby mikedmc » Wed Oct 15, 2008 8:41 am

Thank you alrodopial, that's how I did it but was hoping there was a better way, or at least a better way of getting it done at the right time.

One more think I use Timevalue("00:15:00") but in my case select statement, Timevalue (00:15:00) To Timevalue(00:15:02) doesn't work, I had to do Timevalue(00:15:00), Timevalue("00:15:01") etc. etc.

Again is there a better way?

Thank you.
mikedmc
 
Posts: 79
Joined: Wed May 14, 2008 7:47 pm
Location: London

Postby dgs2001 » Wed Oct 15, 2008 11:04 pm

Mikedmc

Not sure its better, but in order to not miss your time slot you could use the Worksheet calculate event combined with the "Done" flag in AA1.

Set your code to check for the "Done" flag every "worksheet calculate" after time value < 15, and if its not "Done" then do it and set the flag.

Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt


Return to Help

Who is online

Users browsing this forum: No registered users and 56 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.