When there's a lot of meetings with large runner fields, I'm getting very close to exceeding the Transactions per Hour limit that Betfair impose. It's only a matter of time before I start incurring charges. I don't need my lay bets to update with every refresh, once every 30 seconds or so will do, which will reduce my transactions significantly and bring me way below the limit, but once again I'm struggling to implement this in VBA.
Here's a sample of my code, the lay bet is still updating with every refresh instead of once every 30 seconds. Please can someone show me the way?
Cheers
- Code: Select all
Dim startTime As Single
Dim endTime As Single
Dim elapsedTime As Single
Dim currentMarket As String
Dim i As Integer
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
'Upon new market, clear the trigger column, place new bets
If [A1] <> currentMarket Then
currentMarket = [A1]
For i = 5 To 55
Cells(i, 17).Value = ""
Next i
Application.EnableEvents = False
Cells(5, 17).Value = "LAY"
Application.EnableEvents = True
End If
'Update lay bets after 30 second pause
If stopWatch = False Then
startTime = Timer()
stopWatch = True
End If
If stopWatch = True Then
endTime = Timer()
elapsedTime = endTime - startTime
If elapsedTime >= 30 Then
stopWatch = False
elapsedTime = 0
endTime = 0
startTime = 0
' Update bet
Application.EnableEvents = False
Cells(5, 17).Value = "UPDATE"
Application.EnableEvents = True
End If
Else
Cells(5, 17).Value = "counting"
End If
End If
End Sub