VBA help - recording highest and lowest odds

Please post any questions regarding the program here.

Moderator: 2020vision

VBA help - recording highest and lowest odds

Postby Captain Sensible » Thu Nov 01, 2007 12:18 am

Hoping to get some vba code to record the highest and lowest odds for all selections over a time period. I have some code that'll copy and paste the current odds to a cell but I'd like to keep the minmum and maximum odds rather than a snapshot of the odds at a particular time. Does anyone have any similar code or know if it's possible to do with excel ?

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

Postby phrenetic » Thu Nov 01, 2007 1:08 am

Here's what I use:

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Integer
Dim iCol As Integer
Dim cell As Object

For Each cell In Target
  iRow = cell.Row
  iCol = cell.Column

  ' Update Max and Min Back Values
   If iCol = 6 And iRow > 4 And iRow < 46 Then
    Application.EnableEvents = False
    If IsEmpty(Range("AJ" & iRow).Value) Then Range("AJ" & iRow).Value = 0
    If IsEmpty(Range("AI" & iRow).Value) Then Range("AI" & iRow).Value = 1001
    If Not IsEmpty(cell.Value) Then
      If cell.Value < Range("AI" & iRow).Value And cell.Value > 1 Then Range("AI" & iRow).Value = cell.Value
      If cell.Value > Range("AJ" & iRow).Value And cell.Value < 1001 Then Range("AJ" & iRow).Value = cell.Value
    End If
    Application.EnableEvents = True
  End If
 
  ' Update Max and Min Lay Values
  If iCol = 8 And iRow > 4 And iRow < 46 Then
    Application.EnableEvents = False
    If IsEmpty(Range("AL" & iRow).Value) Then Range("AL" & iRow).Value = 0
    If IsEmpty(Range("AK" & iRow).Value) Then Range("AK" & iRow).Value = 1001
    If Not IsEmpty(cell.Value) Then
      If cell.Value < Range("AK" & iRow).Value And cell.Value > 1 Then Range("AK" & iRow).Value = cell.Value
      If cell.Value > Range("AL" & iRow).Value And cell.Value < 1001 Then Range("AL" & iRow).Value = cell.Value
    End If
    Application.EnableEvents = True
  End If
Next cell
End Sub


Columns AI and AJ contain the min and max back values for each horse; Columns AK and AL contain the min and max lay values for each horse.
Rows 5 to 45 contain the details about each runner (allows for 41 runners!) in my spreadsheet.

Hope this helps.

Alistair
phrenetic
 
Posts: 142
Joined: Tue Oct 16, 2007 8:44 pm

Postby Captain Sensible » Thu Nov 01, 2007 5:04 pm

Thanks this is exactly what I was looking for.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 69 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.