Simple VBA code required to record odds periodically

Find a developer for your Excel triggered betting needs and advertise your development service here.

Moderator: 2020vision

Simple VBA code required to record odds periodically

Postby yiangos_shiarlis » Fri Jul 03, 2015 11:11 am

Hi,
Help required to record "Last price matched" odds in column "O" and copied into empty column eg. "AN", after each refresh the odds are again recorded and copied into the next available column eg."AO" and so on........
yiangos_shiarlis
 
Posts: 3
Joined: Fri Jul 03, 2015 10:48 am

Re: Simple VBA code required to record odds periodically

Postby yiangos_shiarlis » Mon Jul 13, 2015 2:38 pm

Hi All,
still no ideas?

I do have from an old spread sheet, this bit of code, but it recorded the odds by row rather column

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Columns.Count = 16 Then
Application.EnableEvents = False

With ThisWorkbook.Sheets(Target.Worksheet.Name)

.Range("J2").Value = "U" 'updates balance and exposure

'copy data to recording sheet
If .Range("U1").Value = "Y" Then
read_range = .Range("A58:AEB58").Value

ThisWorkbook.Sheets("Recorded Odds").Range(ThisWorkbook.Sheets("Recorded Odds").Range("A65536").End(xlUp).Offset(1, 0), _
ThisWorkbook.Sheets("Recorded Odds").Range("A65536").End(xlUp).Offset(1, UBound(read_range, 2) - 1)).Value = read_range
End If

End With
Application.EnableEvents = True
End If

End Sub
yiangos_shiarlis
 
Posts: 3
Joined: Fri Jul 03, 2015 10:48 am

Re: Simple VBA code required to record odds periodically

Postby Captain Sensible » Mon Jul 13, 2015 4:16 pm

Something as simple as this would aacheive what you want just by setting MyCount as a variable and adding 1 on each refresh. I'd imagine it will fill up your sheet pretty quickly though and you'd want to clear the data and reset MyCount hen changing markets too.

Code: Select all
Range(Cells(5, 40 + MyCount), Cells(50, 40 + MyCount)).Value = Range(Cells(5, 15), Cells(50, 15)).Value
MyCount = MyCount + 1



There are quite a few examples of various ways of copying data littered over the forum that may be more relevant to what you're actually trying to acheive though.


Code: Select all


Private Sub Worksheet_Change(ByVal Target As Range)
    Static MyCount As Integer
   
If Target.Columns.Count <> 16 Then Exit Sub
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual



Range(Cells(5, 40 + MyCount), Cells(50, 40 + MyCount)).Value = Range(Cells(5, 15), Cells(50, 15)).Value
MyCount = MyCount + 1



    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
    Exit Sub
   
End Sub

User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: Simple VBA code required to record odds periodically

Postby yiangos_shiarlis » Mon Jul 13, 2015 6:23 pm

Hi Captain Sensible,

I just tried it and it works perfectly, thanks again for taking time to look at this for me, I will adjust the refresh rate so not to over fill. MAGIC!!!

regards
yiangos_shiarlis
 
Posts: 3
Joined: Fri Jul 03, 2015 10:48 am


Return to Find an Excel developer

Who is online

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