Excel Help

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

Moderator: 2020vision

Excel Help

Postby U.F.O » Mon Apr 02, 2018 1:36 pm

Hi, was hoping someone could help with this,
the following VBA code switches to the next event in the quick pick list 10 seconds before start time.

What i would like to add is for it to update a cell on each switch of market, so race 1 of the day would be set to 1 by myself when i set up, and then as it automatically switches to the 2nd, 3rd ,4th event of the day the cell is updated to 2,3,4 and so on.

help would be very much apreatiated
thanks


Option Explicit

Dim currentMarket As String, marketSelected As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
Dim timeFromStart As Date, beforeStart As Boolean, secondsFromStart As Integer
If Target.Columns.Count = 16 Then
Application.EnableEvents = False
If Left([D2], 1) = "-" Then
timeFromStart = Mid([D2], 2)
beforeStart = False
Else
timeFromStart = [D2]
beforeStart = True
End If
secondsFromStart = (Hour(timeFromStart) * 3600) + (Minute(timeFromStart) * 60) + Second(timeFromStart)
If Not beforeStart Then secondsFromStart = -secondsFromStart
If [A1] <> currentMarket Then marketSelected = False
currentMarket = [A1]
If secondsFromStart <= 10 And Not marketSelected Then
marketSelected = True
[Q2] = -1
End If
Application.EnableEvents = True
End If
End Sub
U.F.O
 
Posts: 228
Joined: Tue May 19, 2009 3:21 pm

Re: Excel Help

Postby MarkRussell » Mon Apr 02, 2018 3:02 pm

Hi,

Let's say you are using Z1 for this purpose then where I have added in the code below in red should work.

Regards,
Mark

U.F.O wrote:Hi, was hoping someone could help with this,
the following VBA code switches to the next event in the quick pick list 10 seconds before start time.

What i would like to add is for it to update a cell on each switch of market, so race 1 of the day would be set to 1 by myself when i set up, and then as it automatically switches to the 2nd, 3rd ,4th event of the day the cell is updated to 2,3,4 and so on.

help would be very much apreatiated
thanks


Option Explicit

Dim currentMarket As String, marketSelected As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
Dim timeFromStart As Date, beforeStart As Boolean, secondsFromStart As Integer
If Target.Columns.Count = 16 Then
Application.EnableEvents = False
If Left([D2], 1) = "-" Then
timeFromStart = Mid([D2], 2)
beforeStart = False
Else
timeFromStart = [D2]
beforeStart = True
End If
secondsFromStart = (Hour(timeFromStart) * 3600) + (Minute(timeFromStart) * 60) + Second(timeFromStart)
If Not beforeStart Then secondsFromStart = -secondsFromStart
If [A1] <> currentMarket Then marketSelected = False
currentMarket = [A1]
If secondsFromStart <= 10 And Not marketSelected Then
marketSelected = True
[Q2] = -1
[Z1] = [Z1]+1
End If
Application.EnableEvents = True
End If
End Sub
User avatar
MarkRussell
Site Admin
 
Posts: 1787
Joined: Tue Feb 20, 2007 6:38 pm
Location: Birmingham


Return to Discussion

Who is online

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

cron