Changing to next race in VBA

Please post any questions regarding the program here.

Moderator: 2020vision

Changing to next race in VBA

Postby alanh99 » Wed Sep 07, 2011 6:40 am

Hi Gary and/or anyone who can help,

I have set up some VBA which monitors prices and amounts bet up to the time a race goes In Play or Suspended. At this point I want to change to the next race in my Quick Pick list. I therefore get VBA to put -1 in Q2. To my frustration, even though on next click, if Q2 is -1, I change Q2 to 5 (as in seconds refresh) BA always jumps two races, ie reads the -1 twice. What to do please?
alanh99
 
Posts: 13
Joined: Wed May 11, 2011 12:09 am

Postby GaryRussell » Wed Sep 07, 2011 7:35 am

The Worksheet_Change event is fired multiple times on each refresh. You should make sure your code only runs in the refresh that updates the odds. Also prevent the worksheet event being fired by inserting -1 by disabling events while you change it.

example code
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Columns.Count = 16 Then
        Application.EnableEvents = False
        [Q2] = -1
        Application.EnableEvents = True
    End If
End Sub
User avatar
GaryRussell
Site Admin
 
Posts: 9872
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby alanh99 » Wed Sep 07, 2011 11:06 am

Thanks for the rapid reply. I think I get the idea. I will try it out and hopefully, all is solved.

cheers, Alan H
alanh99
 
Posts: 13
Joined: Wed May 11, 2011 12:09 am

Postby Raiden » Fri Nov 11, 2011 7:22 pm

Hey, I have a similar problem:

I've written this code to skip markets after the race is over
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Columns.Count = 16 Then
        Application.EnableEvents = False
    If Tabelle1.Cells(2, 5) = "In Play" And Tabelle1.Cells(2, 6) = "Suspended" Then
        Tabelle1.Cells(2, 17) = -1
    End If
    Application.EnableEvents = True
    End If
End Sub


Now BA skips 2 markets, when the race is over.
Is there any way to avoid that?

Thanks
Raiden
 
Posts: 8
Joined: Fri Nov 11, 2011 12:56 pm

Postby MarkRussell » Fri Nov 11, 2011 7:59 pm

Hi,

Have a look at the code in the following example which will solve your problem:-

http://www.gruss-software.co.uk/forum/viewtopic.php?t=5163

Regards,
Mark
User avatar
MarkRussell
Site Admin
 
Posts: 1793
Joined: Tue Feb 20, 2007 6:38 pm
Location: Birmingham


Return to Help

Who is online

Users browsing this forum: No registered users and 65 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.