Excel trigger after before moving to next market

Please post any questions regarding the program here.

Moderator: 2020vision

Excel trigger after before moving to next market

Postby vanbuuts » Mon Nov 26, 2018 3:40 pm

All, below is probably a familiar bit of code, it switches to the next market - for me based on cell AB1 = "OK"

I want to run a macro when cell Y1= "OK" - however, I'm not sure where to add this into the code below to ensure both macro's run each race. When I have tried to put this into the code below (in between the End If and enable events = true it runs once and then the macro to skip to the next race never fires again.

Looking for some help if possible to be able to run 2 macro's without any confliction of one stopping the other other working again

Code: Select all

Private Sub Worksheet_Change(ByVal Target As Range)

 If Target.Columns.Count = 16 Then
        Application.EnableEvents = False
       
           If [A1] <> currentMarket Then marketSelected = False
        currentMarket = [A1]
        If [AB1] = "OK" And Not marketSelected Then
            marketSelected = True
              ThisWorkbook.Sheets("Race1").Select
                                            [Q2] = -1
                                              End If
                                             
             
         
                                                         
                                                         
        Application.EnableEvents = True
       
End If



Code: Select all
If [Y1] = "OK" Then
           
           Call get_updates
vanbuuts
 
Posts: 321
Joined: Thu Oct 16, 2014 8:55 pm

Re: Excel trigger after before moving to next market

Postby Captain Sensible » Mon Nov 26, 2018 4:27 pm

In your current code the first If statement is controlling everything , it opens at

Code: Select all
If [A1] <> currentMarket



and ends, somewhat weirdly, after the
Code: Select all
 Application.EnableEvents = True


This means that unless [A1] <> currentMarket none of your code will be executed.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: Excel trigger after before moving to next market

Postby Captain Sensible » Mon Nov 26, 2018 4:31 pm

You could try something like this

Code: Select all
    Private Sub Worksheet_Change(ByVal Target As Range)

     If Target.Columns.Count = 16 Then
            Application.EnableEvents = False
           
            If [A1] <> currentMarket Then marketSelected = False:  currentMarket = [A1]
            If [Y1] = "OK" Then Call get_updates

                If [AB1] = "OK" And Not marketSelected Then
                marketSelected = True
                ThisWorkbook.Sheets("Race1").Select
                                                [Q2] = -1
                                                  End If
                                                 
                 
             
                                                             
                                                             
            Application.EnableEvents = True
           

End Sub





User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: Excel trigger after before moving to next market

Postby Captain Sensible » Mon Nov 26, 2018 4:34 pm

Missed out an end if, should be something like this. I haven't tested it , so check it works before betting with it. Also you should probably code it to the sheet rather than just having open references like [A1] etc as if you were looking at a different sheet when the code executed it would execute on whatever sheet you had open, i.e. sheet2 rather than the sheet1 you wanted.

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)

     If Target.Columns.Count <> 16 Then Exit sub

            Application.EnableEvents = False
           
            If [A1] <> currentMarket Then marketSelected = False:  currentMarket = [A1]
            If [Y1] = "OK" Then Call get_updates

                If [AB1] = "OK" And Not marketSelected Then
                marketSelected = True
                ThisWorkbook.Sheets("Race1").Select
                                                [Q2] = -1
                                                  End If
                                                 
                 
             
                                                             
                                                             
            Application.EnableEvents = True
           

End Sub

User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: Excel trigger after before moving to next market

Postby vanbuuts » Mon Nov 26, 2018 4:36 pm

Thanks very much that is helpful
vanbuuts
 
Posts: 321
Joined: Thu Oct 16, 2014 8:55 pm


Return to Help

Who is online

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