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
Building a stop clock in visual basic
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.
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.