Building a stop clock in visual basic

Discussion regarding the spreadsheet functionality of Bet Angel.
Post Reply
User avatar
Orixian
Posts: 78
Joined: Sun Sep 06, 2015 12:36 am

I am trying to build a clock that commences at a certain trigger e.g. event start then stops at any suspensions then resumes again when in play status comes back and the suspended status goes away.

Ive been using visual basic and have come up with the following set of sub routines. In The code below K26 is the cell that registers wether a market is in play or not by getting this information from the betfair template workbook that comes with betfair pro. Cell N33 contains the clock. I have an active X button linked to the macro to trigger it.


Sub Starttimer()
If Range("K26") ="In Play" Then
Application.OnTime Now + TimeValue("00:00:01"), "O_Sec"
Else
Starttimer

End If

End Sub
-----------------------------------------------------------------------------------------------
Sub O_Sec()
Starttimer
Range("N33").Value = Range("N33").Value + TimeValue("00:00:01")


End Sub
------------------------------------------------------------------------------------------------------


As far as I can tell this should cause the clock to keep checking if in play is being displayed in the relevant cell and stoping and starting accordinly. What I get instantly when I hit the macro start button is a stack error and excell crashes. I can build a clock that starts and stops if Im there to manually push the buttons but thats no use to me.

Any help would be appreciated. Today is the first time I have ever used visual basic so any solution might take some explaining.

Kind Regards
Xion
Posts: 11
Joined: Fri Jul 04, 2014 1:32 pm

Hi

I'm not sure I fully understand. Is the reason for this clock just to count the time a market is In Play? More detail would help.

Does it have to be in VB or is formula an option?
User avatar
Orixian
Posts: 78
Joined: Sun Sep 06, 2015 12:36 am

Hi the point for the clock was data capture. I wanted to capture the data on the odds of a market every 30 seconds after the off (Infact Xion I took the code you suggested on another thread and adapted it for this purpose).

My code was basically dependant on the time of the event. Unfortunately when that time whent negative after the event ended all my data collection was wiped. i couldn't figure out how to stop this from happening using the excell code (theres probably a way) so I thought id build a clock in Vba that starts counting when the market goes in play. The added bonus to my clock however is that it doesnt continue to count when the market is suspended so I dont collect data from suspended markets (useless data I cant trade off it, as the market will be suspended).

The clock then resumes counting when the market goes inplay again. So I can generate an accurate picture of odds movement in a market accross an event without event stoppages poluting the data. I have finally built the clock too and its currently sucessfully pulling the data.
nigelk
Posts: 469
Joined: Wed Apr 15, 2009 11:00 pm

If you want something to run without the need for pushing buttons then the code will have to go in as an sheet event (calculate or change) and not in a regular module.
User avatar
Orixian
Posts: 78
Joined: Sun Sep 06, 2015 12:36 am

Yes it did need sheet event code to get it to work. That was the final step.
Xion
Posts: 11
Joined: Fri Jul 04, 2014 1:32 pm

Glad you sorted it out.

I think your problem is also easily fixed with formula. If you need any help with that, let me know.
warren0
Posts: 82
Joined: Thu Jun 02, 2016 4:12 pm

Just wondered what the solution macro was to the timer being triggered by the event ie In Play cell etc.

Also interested how that would be done by formula for my own Excel knowledge?

Thanks
Post Reply

Return to “Bet Angel - Spreadsheet / Excel chat”