vba help

Please post any questions regarding the program here.

Moderator: 2020vision

Re: vba help

Postby Captain Sensible » Thu Jul 27, 2017 5:44 pm

Haven't had time to look at your myQ2 code so not sure what you're trying to do with it to be honest, I'd imagine it's skipping races because it's maybe not clearing variables when you enter a new market. You should also consider looking at clearing cells when you enter a market too as I can't see any code to do that either. Probably a bit of a blessing it's not working because it'd be placing bets as soon as it enters a markets at the moment.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: vba help

Postby Captain Sensible » Thu Jul 27, 2017 8:46 pm

Here's some code for you to play around with to switch between markets, it's basically the same code I use so I know it works.

It's easier for me to just copy and paste something I use rather than try and unravel why your MyQ2 code isn''t working tbh. Just try and understand what it's doing before throwing other coding into it, there's also plenty of bits you can take out later where it's just echoing the status of any variables to the screen whilst you try to understand it. It needs the Function LastRow in a module for it to work but otherwise shoud be fine, just add the reset macro into the module also so it's ready for any amendments.

Code: Select all
Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    Static MyMarket As String, Streaming As String, exitingMarket As String
    Dim rowFindLast As Integer
       
   
        If Target.Columns.Count <> 16 Then Exit Sub
        Application.EnableEvents = False


        With Target.Parent
       
                'Let's display the status whilst developing''
        .Range("S1").Value = "Your code has stopped"
        .Range("S2").Value = "Exciting market : " & exitingMarket
        .Range("S3").Value = "Streaming is " & Streaming
        '''''Just delete or comment out when no longer needed '''''
     
        ' Let's set up the new market
         If .Range("A1").Value <> MyMarket Then GoTo marketSetup
         ' Let's set up the new market
         
         ' simple routine to move between markets
         If (.Range("E2").Value = "In Play" And .Range("F2").Value <> "") Or .Range("F2").Value = "Closed" Then
         If exitingMarket = "NO" Then .Range("Q2").Value = -1
         exitingMarket = "YES"
         GoTo xit: ' no point running thru the rest of our code
         ElseIf .Range("E2").Value = "In Play" Then
         If Streaming <> "ON" Then Streaming = "ON": .Range("Q2").Value = "FULL-STREAM-ON"
         Else
         If Streaming <> "OFF" Then Streaming = "OFF": .Range("Q2").Value = "FULL-STREAM-OFF"
         End If
         ' simple routine to move between markets
         
       
         
         
         'your main code routines can go in here
         
         
         
         
         
         
         
         
         
         
         

       
       
       
       
xit:

        Application.EnableEvents = True
        .Range("S1").Value = "Enable Events is " & Application.EnableEvents
            End With
        Exit Sub
       
       
marketSetup: 'let's cleanup from the previous market and reset any variables
 With Target.Parent
        MyMarket = .Range("A1").Value
        exitingMarket = "NO"
        Streaming = ""
        rowFindLast = LastRow(.Range("Q:U"), 0)
        .Range("Q2,Q5:U" & rowFindLast).Value = ""

       

        Application.EnableEvents = True
        .Range("S1").Value = "Enable Events is " & Application.EnableEvents
        End With
    End Sub
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: vba help

Postby mak » Fri Jul 28, 2017 10:51 am

Thanks a lot Captain!
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Previous

Return to Help

Who is online

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