Cell Q2 trigger confusion

Please post any questions regarding the program here.

Moderator: 2020vision

Cell Q2 trigger confusion

Postby osknows » Sun Aug 02, 2009 3:12 pm

I'm attempting to forward the pick list by one when the current race has finished using

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
 
 If Target.Columns.Count = 16 Then

Application.EnableEvents = False

    Cells(2, 10).Value = "U" 'updates balance and exposure
    If Cells(2, 5).Value = "In Play" And Cells(2, 6).Value = "Suspended" And Cells(2, 17).Value <> -1 Then
        Cells(2, 17).Value = -1
       
    Else
        Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"
    End If
   
           
End If
Application.EnableEvents = True


However, this cyles forward 2 races and not just 1?

So I thought ok, clear out the Inplay and suspended cells to avoid re-trigger using
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
 
 If Target.Columns.Count = 16 Then

Application.EnableEvents = False

    Cells(2, 10).Value = "U" 'updates balance and exposure
    If Cells(2, 5).Value = "In Play" And Cells(2, 6).Value = "Suspended" And Cells(2, 17).Value <> -1 Then
        Cells(2, 17).Value = -1
       Cells(2, 5).Value = ""
       Cells(2, 6).Value = ""
    Else
        Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"
    End If
   
           
End If
Application.EnableEvents = True
End Sub


But this does the same. Can anyone see why this is?

Thanks,
Os
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby greenfingers » Thu Aug 06, 2009 1:13 pm

Afraid I'm not a good programmer so I don't understand your code, however I had a similar problem (moving forward 2 races at the end of current one) and solved it.

What I finally figured out is that once you request the next race in Q2, there is a further refresh of the data to excel before moving on to the next race, so you need to be sure not to put -1 in Q2 at this point so that it doesn't then receive a second request.

I did this by using a variable as a flag when I put -1 into Q2 and then checking the value of the flag after the refresh so that my code to put -1 in Q2 would not be re-executed.

I know I've explained this badly but hopefully it will steer you in the right direction. Cheers! :D
User avatar
greenfingers
 
Posts: 214
Joined: Mon Mar 23, 2009 3:10 pm

Postby osknows » Thu Aug 06, 2009 6:18 pm

Thanks. I did figure it out myself and used your exact method to flag a variable whether -1 had already been triggered. It appears when BA refreshes after a trigger it clears out the cell in excel
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby silver » Thu Sep 03, 2009 11:47 am

Is it possible for someone who has solved this issue to post the correct code? I have read osknow's description of the solution, but I don't know how to implement it.

S
silver
 
Posts: 42
Joined: Thu Sep 03, 2009 10:50 am

Postby osknows » Thu Sep 03, 2009 12:01 pm

Code: Select all
    'forward quick pick race on after race ended
    If Cells(2, 5).Value = "In Play" And Cells(2, 6).Value = "Suspended" And UCase(Cells(1, 17).Value) = "Y" And nextracetrigger = 0 Then
    Application.EnableEvents = False
        nextracetrigger = 1
        lastrace = Cells(1, 1).Value
        Cells(2, 17).Value = -1
     Application.EnableEvents = True
    End If
   
    If lastrace <> Cells(1, 1).Value Then
    Application.EnableEvents = False
        nextracetrigger = 0
        Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"
    Application.EnableEvents = True
    End If


Since cell Q2 is used for both market selection and refresh rate the following line:
Cells(2, 17).FormulaR1C1 = "=IF(OR(RC[-11]=""Suspended"",RC[-11]=""Closed""),1,IF(ISERROR(IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)),0.2,IF(AND(HOUR(RC[-13])=0,MINUTE(RC[-13])<=1),0.2,1)))"

just places a formula back into Q2 which sets the refresh rate to 1 sec and 0.2 thirty seconds before the off

also Cells(1, 17).Value) = "Y" is cell Q1 which i use to enable/disable forwarding of the quick pick list
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby silver » Thu Sep 03, 2009 1:20 pm

Thanks for sharing this excellent code, very helpful! The enable/disable trigger is a nice inclusion. :D
silver
 
Posts: 42
Joined: Thu Sep 03, 2009 10:50 am

Postby mak » Mon Sep 07, 2009 3:57 pm

Osknows hi,
I copy paste your latest code in a "Private Sub Worksheet_Change(ByVal Target As Range)" but it still forwarding 2 races..

Any ideas?

** I don't know if it has to do with the nextracetrigger, I can't understund where it "reads" 0 or 1

thanx
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby osknows » Mon Sep 07, 2009 7:57 pm

User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am


Return to Help

Who is online

Users browsing this forum: Majestic-12 [Bot] and 51 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.