Macro Help

Find a developer for your Excel triggered betting needs and advertise your development service here.

Moderator: 2020vision

Macro Help

Postby Shaun » Thu Jun 04, 2009 1:07 am

Hi,

I have a sheet that was given to me that is supposed to download the race ID from gruss, problem is it only works sometimes and i have no idea why.

Can someone have a look and possible make the changes so it will work everytime or if there is a particular way i should be running it.
Code: Select all
Option Explicit

Dim sRaceDets As String
Dim wb1 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet

' ------------------------------------
' PROCESS ALL CHANGES TO THE WORKSHEET
' ------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim iReturn As Integer
 
  ' Only process whole updates
  If Target.Columns.Count <> 16 Then Exit Sub
 
  ' Set-up workbook variables
  Set wb1 = ThisWorkbook
  Set ws1 = wb1.Sheets("SH_DetectRaces")
  Set ws2 = wb1.Sheets("SH_TodaysRaces")
 
  ' Stop any further updates until we have completed
  Application.EnableEvents = False
 
  ' Initialise the bot on the first pass through
  If ws1.Range("AB5").Value = "N" Then
    Call InitialiseSheet
  Else
    ' Check for a new race
    If ws1.Range("A1").Value <> sRaceDets Then
      sRaceDets = ws1.Range("A1").Value
      ws1.Range("AB7").Value = ws1.Range("AB6").Value
      ws1.Range("AB8").Value = "N"
    End If
   
    ' Check to see if the race should be copied to the log
    If ws1.Range("AB8").Value = "N" And ws1.Range("AB7").Value <> 0 And Abs(ws1.Range("AB7").Value - ws1.Range("AB6").Value) >= 1 Then
      Call LogRaces
      ws1.Range("AB8").Value = "Y"
      ' Update the spreadsheet to move to the next race in the quick pick list
      ws1.Range("Q2").Value = -1
    End If
  End If
 
  ' Enable events as all updates have been completed
  Application.EnableEvents = True
End Sub

' --------------
' INITIALISATION
' --------------
Sub InitialiseSheet()
  sRaceDets = ""
  ws1.Range("AB5").Value = "Y"
  ws1.Range("AB7").Value = 0
  ws1.Range("AB8").Value = "N"
End Sub

' -----------------------------
' COPY THE RACE NAME TO THE LOG
' -----------------------------
Sub LogRaces()
  Dim logRow As Integer
  Dim theRow As Integer
 
  ' Find out the row number for the next blank line in the log
  logRow = ws2.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
 
  ' Copy the details to the log
  ws2.Range("A" & logRow).Value = sRaceDets
End Sub


All these macros are contained on the one sheet "detectraces"
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia

Postby Shaun » Thu Jun 04, 2009 1:16 am

Here is a funny thing, the sheet was set on manual calculation when i changed it to automatic it started to work fine.

We will see how it goes.
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia


Return to Find an Excel developer

Who is online

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