This code records prices - can someone adjust for me.

Discussion regarding the spreadsheet functionality of Bet Angel.
Post Reply
Valda
Posts: 106
Joined: Mon Sep 17, 2018 8:11 pm

Found these code snippets and they work - you can alter the recording range and the seconds between records to whatever you want.
Can anyone help me adjust these please so that it starts recording on auto-bind and clears the data ready for the next market on auto-clear.
i only want to record from 4 minutes out until post time, and restart automatically on each new market.


'This code should go in a regular module sheet, and won't work properly if installed anywhere else. _
The next (Dim) statement must occur before any subs or functions.
Dim NextTime As Double

Sub RecordData()
Dim Interval As Double
Dim cel As Range, Capture As Range
Interval = 5 'Number of seconds between each recording of data
Set Capture = Worksheets("Sheet1").Range("A1:A5") 'Capture this column of data
With Worksheets("Sheet2") 'Record the data on this worksheet
Set cel = .Range("A2") 'First timestamp goes here
Set cel = .Cells(.Rows.Count, cel.Column).End(xlUp).Offset(1, 0)
cel.Value = Now
cel.Offset(0, 1).Resize(1, Capture.Cells.Count).Value = Application.Transpose(Capture.Value)
End With

NextTime = Now + Interval / 86400
Application.OnTime NextTime, "RecordData"
End Sub

Sub StopRecordingData()
On Error Resume Next
Application.OnTime NextTime, "RecordData", , False
On Error GoTo 0
End Sub

'These subs must go in ThisWorkbook code pane. They won't work at all if installed anywhere else!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopRecordingData
End Sub

Private Sub Workbook_Open()
RecordData
End Sub
Valda
Posts: 106
Joined: Mon Sep 17, 2018 8:11 pm

Hmm I’ll try to see if I can incorporate some of Switech’s code. VBA is a long hard flog for me, lot of trial and error, mostly error.
Valda
Posts: 106
Joined: Mon Sep 17, 2018 8:11 pm

Yay - got there - all the help much appreciated. :D
Anbell
Posts: 2004
Joined: Fri Apr 05, 2019 2:31 am

Valda wrote:
Wed Jul 01, 2020 7:54 am
Yay - got there - all the help much appreciated. :D
How did you do it?
Valda
Posts: 106
Joined: Mon Sep 17, 2018 8:11 pm

Trial and error - took some of the code above and some of the code from Switesh’s sheet (it’s on here somewhere) and fiddled about till I got what I wanted.
Anbell
Posts: 2004
Joined: Fri Apr 05, 2019 2:31 am

Valda wrote:
Wed Jul 01, 2020 10:44 am
Trial and error - took some of the code above and some of the code from Switesh’s sheet (it’s on here somewhere) and fiddled about till I got what I wanted.
Good to hear that you got there.

Could you please be more specific about your solution?
Post Reply

Return to “Bet Angel - Spreadsheet / Excel chat”