Copying MyBets to a new sheet to keep history

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

Moderator: 2020vision

Copying MyBets to a new sheet to keep history

Postby fusela » Tue Jul 28, 2020 10:26 am

Hi There,
I am new to the software and am a complete vba newbie. I have no issues with working out Excel Syntax/Formulas or recording macros with the macro recorder, however I am not great at coding.

I understand the MyBets tab is refreshed when the market changes so if bets are placed they are lost when the market changes.
I am looking to implement a strategy based on historical bets placed in the day so would like to write copy mybets to another tab maybe called "history"
I think that Private Sub Worksheet_Change is ideal for this. I have been able to find examples for this to move single cells but I can workout how to move rows. This is what I'd like to achieve as an example
1. First race of the day is 12:20 southwell - single back bet placed and recorded in mybets
2. Copy row 2 to history (first row is headers)
3. Second race of the day is 12:50 Southwell, mybets has cleared
4. single back bet is placed and recorded in row 2 of mybets
5. I would like this bet to be copied to be copied to the next available row in history (row 3)
6. Race 3 goes foes to row 4 and so on....

Any idea on how to easily implement this?

Cheers!
fusela
 
Posts: 13
Joined: Tue Jul 28, 2020 10:16 am

Re: Copying MyBets to a new sheet to keep history

Postby Captain Sensible » Wed Jul 29, 2020 6:12 pm

To move a row you'd simply select a range of cells rather than a single cell , something like


Code: Select all
Worksheets("MyBets").Range("A2:F2").Value


To place that data into the next available cell below you can use End(xlUp).Row to find the last row in the sheet with data. So to stick the last row into a variable we'd say

Code: Select all
Dim lastrow As Long

lastrow = Worksheets("BetHistory").Range("A" & Rows.Count).End(xlUp).Row


Now we know the last row with data we can simply add 1 to it to get the next free row and stick our data in there


Code: Select all

Worksheets("BetHistory").Range("A" & lastrow + 1 & ":F" & lastrow + 1).Value = Worksheets("MyBets").Range("A2:F2").Value



Alternatively if you want things in reverse you simply use Insert (xlShiftDown) and shift the data down one row before entering your new data

Code: Select all
Worksheets("BetHistory").Range("A2:F2").Insert (xlShiftDown)
Worksheets("BetHistory").Range("A2:F2").Value = Worksheets("MyBets").Range("A2:F2").Value



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

Re: Copying MyBets to a new sheet to keep history

Postby fusela » Thu Jul 30, 2020 3:40 pm

Great - Many thanks for taking the time to gt back to me. I will have a look at your code snippets and give it a go!

-fusela
fusela
 
Posts: 13
Joined: Tue Jul 28, 2020 10:16 am


Return to Discussion

Who is online

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