Excel Function or Macro

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Excel Function or Macro

Postby AndrewP » Sat Nov 10, 2007 5:28 pm

Hi All,

Can anyone help me with an Excel function or macro?

What I want to do is determine the prices at which I will back or lay selections from their last traded prices. It's easy enough to put formulae in Excel to do this but I don't want them to be dynamic and alter as the last traded price updates. I would like the last traded prices to be read once upon (auto) selection and my back and lay prices claculted from this reading with no further updating. How can I do this?

Regards,

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby phrenetic » Sat Nov 10, 2007 9:12 pm

Andrew

Try this:
Code: Select all
Public sRaceDets As String

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

  ' Check for new race being loaded
  If iCol = 1 And iRow = 1 Then
    If LCase(cell.Value) <> sRaceDets Then
      sRaceDets = LCase(cell.Value)

      ' Copy last matched prices into column AA
      Application.EnableEvents = False
      For theRow = 5 To 44
        Range("AA" & theRow).Value = Range("O" & theRow).Value
      Next theRow
      Application.EnableEvents = True
    End If
  End If
Next cell
End Sub


It will copy the last price matched values into column AA whenever a race is selected.

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

Postby AndrewP » Sat Nov 10, 2007 9:44 pm

Alistair,

Thank you for this.

Forgive my ignorance but can you explain blow by blow what I do with the code? I'm afraid I'm a novice when it comes to VB although I understand basic Excel spreadsheets well.

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby phrenetic » Sat Nov 10, 2007 11:19 pm

Andrew

Just right click on the tab for the worksheet that you are linking to BA and select the View Code option. A macro coding sheet will be opened.

Cut and paste the function from my previous message into the coding sheet. Save the macro and close the macro coding sheet.

Now whenever a new race is selected by BA, the spreadsheet will be updated and the last matched price values will be copied into column AA automatically.

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

Postby AndrewP » Sun Nov 11, 2007 12:07 am

Thanks again Alistair, it works perfectly.

Regards,

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby AndrewP » Sat Dec 01, 2007 4:29 pm

Alistair,

Can I be really cheeky and ask if you could modify the code to capture last matched prices to column AH when cell W1 reads "In Play" rather than upon loading the race? I have another strategy I would like to try out.

Thanks,

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby phrenetic » Sat Dec 01, 2007 4:37 pm

Sure - I'll post something later this afternoon.

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

Postby phrenetic » Sat Dec 01, 2007 11:26 pm

Andrew

*** Note - due to a complete Internet outage this evening, I have not been able to test this ****

Try this:

Code: Select all
Public bOddsCopied As Boolean
Public sRaceDetails As String

Private Sub Worksheet_Calculate()
   ' Reset the flags if a new race is loaded
  If LCase(Range("A1").Value) <> sRaceDets Then
    sRaceDets = LCase(Range("A1").Value)
    bOddsCopied = False
  End If
   
  ' Check to see if race has just gone In-Play (status is held in cell W1)
  If LCase(Range("W1").Value) = "in play" And bOddsCopied = False Then
    ' Copy last matched prices into column AH
    Application.EnableEvents = False
    For theRow = 5 To 44
      Range("AH" & theRow).Value = Range("O" & theRow).Value
    Next theRow
    Application.EnableEvents = True
    bOddsCopied = True
  End If
End Sub     


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

Postby AndrewP » Sun Dec 02, 2007 1:17 am

Alistair,

I tested the code by auto selecting the US market and simulating cell W1 turning 'in play' and it seems to work just fine. I'll let you know how it fares in the UK market when turning 'in play' for real.

I really am most grateful to you for this, it would take me ages to work it out for myself.

Best regards,

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby AndrewP » Sun Dec 02, 2007 2:03 pm

Alistair,

In testing the code on 'in play' markets I see that as my 'in play' flag in cell W1 refreshes so do the prices in column AH. It is effectively therefore giving me the same last traded prices as colunm O. My intention was to capture the last traded prices just as the market turns in play (BA seems to allow for the market to settle down) and not keep refreshing them. Is there a way of doing this?

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am

Postby Captain Sensible » Sun Dec 02, 2007 5:37 pm

Andrew try amending the line

Public sRaceDetails As String


to

Public sRaceDetls As String

and it should hopefully work
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Sun Dec 02, 2007 5:44 pm

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

Postby phrenetic » Sun Dec 02, 2007 5:57 pm

Andrew

Sorry - the dangers of posting something without being able to check it first.

As Captain Sensible says, just change the line to read:

Public sRaceDets As String

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

Postby AndrewP » Mon Dec 03, 2007 12:09 am

Thanks Guys, I'll give it a whirl tomorrow.

Andrew
AndrewP
 
Posts: 39
Joined: Sat Nov 03, 2007 10:52 am


Return to Discussion

Who is online

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