Some Excel help required

Please post any questions regarding the program here.

Moderator: 2020vision

Some Excel help required

Postby doris_day » Wed Sep 21, 2011 8:49 am

If certain conditions are present I want Excel to trigger a move to the next race and I've been using the code provided from Osknows viz:

Dim marketChanging As Boolean, currentMarket As String

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Columns.Count <> 16 Then Exit Sub
Application.EnableEvents = False


With ThisWorkbook.Sheets(Target.Worksheet.Name)
If Not marketChanging And .Range("THIS CELL").Value = "THIS VALUE" Then
marketChanging = True
currentMarket = .Range("A1").Value
.Range("Q2").Value = -1
Else
If .Range("A1").Value <> currentMarket Then marketChanging = False
.Range("Q2").Formula = "=ADD YOUR FORMULA"
End If
End With

Application.EnableEvents = True

End Sub

That seems to work fine although, because I'm getting data from another source too I need to wait for about 5 seconds after a new market has been loaded before starting the routine. I've tried a "WAIT" line of code viz Application.Wait (Now() + "00:00:05") where I thought appropriate but its not working and I'm not certain this is the correct routine required anyway.
Basically, I want to load the first race of the day, once loaded with Betfair wait 5 secs so other data source can load and calculations be made, then if CellX >= Y move forward to next race, Else keep checking CellX after each normal refresh etc

Any help appreciated.
'He was looking for the card so high and wild he'd never need to deal another' - Leonard Cohen
User avatar
doris_day
 
Posts: 968
Joined: Fri Nov 02, 2007 12:34 am

Postby Captain Sensible » Wed Sep 21, 2011 12:14 pm

Have you considered using a variable to count each refresh? I had something similar than waited for conditions to be met but also did a further critieria of 10 refreshes before moving on.

So you code would be amended a bit like

Dim counter as currency

If Not marketChanging And .Range("THIS CELL").Value = "THIS VALUE" Then
counter=counter+1


ElseIf Not marketChanging And .Range("THIS CELL").Value = "THIS VALUE" And counter >10 Then
counter=0
....... other code

[/i][/quote]
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Ian » Wed Sep 21, 2011 12:29 pm

How are you getting your data from the other source ?
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby doris_day » Wed Sep 21, 2011 12:53 pm

Magic Captn. That did the trick...

Ian, I'm scraping Ladbrokes with some regex VBA Osknows wrote for me and which works well.
'He was looking for the card so high and wild he'd never need to deal another' - Leonard Cohen
User avatar
doris_day
 
Posts: 968
Joined: Fri Nov 02, 2007 12:34 am

Postby Ian » Wed Sep 21, 2011 2:46 pm

I was going to suggest that you have a flag which you turn off when going into the scraping routine and turn on when you exit it and then test the flag subsequently.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby doris_day » Wed Sep 21, 2011 3:03 pm

Thanks for the suggestion Ian.
'He was looking for the card so high and wild he'd never need to deal another' - Leonard Cohen
User avatar
doris_day
 
Posts: 968
Joined: Fri Nov 02, 2007 12:34 am


Return to Help

Who is online

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