Using more than one workbook

Please post any questions regarding the program here.

Moderator: 2020vision

Using more than one workbook

Postby vanbuuts » Thu Jun 29, 2017 5:43 pm

Hi, I have been splitting races to separate tabs and trying to use a different workbook for each meeting.

Some of my code is below, and only works on the workbook that is active

The code below is when a race ends and moves to the next race. However it only fires on the active file / sheet.

Anyone have any experience of using VBA calls with multiple sheet / workbooks for different races?

Code: Select all
Range("Z1").Select
    ActiveCell.FormulaR1C1 = "=SUM(R5C26:R60C26)"
    Range("T5:X60").ClearContents
    Range("AM5:AM60").ClearContents
vanbuuts
 
Posts: 326
Joined: Thu Oct 16, 2014 8:55 pm

Re: Using more than one workbook

Postby Daywalker » Thu Jun 29, 2017 7:57 pm

Hi Vanbuuts,

I have four excel workbooks open and four tabs in Gruss open. I have different markets loaded into each tab and it works fine. My code in each work book, after checking for 16 columns updated, is enclosed in a With Workbooks (see below).

Does each of your workbooks have a unique name? This prevents any mix up.

Also I have separate instances of Excel for each workbook, rather than opening each workbook from within one excel window.

I've had issues in the past with referencing cells/sheets. When this has happened I've found the best solution is to fully reference things, for example instead of Range("Z1").Select, use Worksheets("Sheet1").Range("Z1").Select

T
Code: Select all
Public Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count <> 16 Then Exit Sub
Application.EnableEvents = False

With Workbooks("THE NAME OF THIS WORKBOOK").Sheets(Target.Worksheet.Name)   
  '
  'All your code goes here
  '
End With

Application.EnableEvents = True
End Sub
I have a blog https://trader247.uk
User avatar
Daywalker
 
Posts: 200
Joined: Wed Aug 18, 2010 11:43 pm
Location: Mid-West Yorkshire

Re: Using more than one workbook

Postby vanbuuts » Tue Jul 04, 2017 1:36 pm

Thanks for your reply, I will give it a go - I did try and refer to the individual sheet but didn;t seem to work (had bets firing in all over the place).

At the moment I am getting "General API error" while trying to access GRUSS so am not able to do any further checking
vanbuuts
 
Posts: 326
Joined: Thu Oct 16, 2014 8:55 pm

Re: Using more than one workbook

Postby Drunkenight » Tue Jul 04, 2017 1:38 pm

Yes Betfair is down and has been for almost an hour. Hope it comes back soon.
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Re: Using more than one workbook

Postby vanbuuts » Thu Jul 06, 2017 6:46 pm

I can see where the problem is coming from. I use the "mybets" worksheet - and when you have markets that overlap, "mybets" seems to alternate between which horses are placed in the sheet.

Basically they don't stack they try and overlap.

Surely someone must have overcome this? Seems like a software flaw. Is there a way to separate horses from different markets in the "my bets" sheet as mine just alternate between the 2 races that I am betting on simultaneously
vanbuuts
 
Posts: 326
Joined: Thu Oct 16, 2014 8:55 pm

Re: Using more than one workbook

Postby vanbuuts » Thu Jul 06, 2017 7:15 pm

AHah! Solved by using Sheet1_MyBets, Sheet2_MyBets etc
vanbuuts
 
Posts: 326
Joined: Thu Oct 16, 2014 8:55 pm

Re: Using more than one workbook

Postby MarkRussell » Thu Jul 06, 2017 7:16 pm

vanbuuts wrote:I can see where the problem is coming from. I use the "mybets" worksheet - and when you have markets that overlap, "mybets" seems to alternate between which horses are placed in the sheet.

Basically they don't stack they try and overlap.

Surely someone must have overcome this? Seems like a software flaw. Is there a way to separate horses from different markets in the "my bets" sheet as mine just alternate between the 2 races that I am betting on simultaneously


Hi,

If you are logging to multiple worksheets and want to use the MyBets sheet then you need a separate MyBets sheet for each market that you are logging to.
So say you are logging a market to Sheet1 then you should name the MyBets sheet Sheet1_MyBets and then if you are logging another market to Sheet2 the MyBets for that one should be named Sheet2_MyBets and so on.

Regards,
Mark
User avatar
MarkRussell
Site Admin
 
Posts: 1793
Joined: Tue Feb 20, 2007 6:38 pm
Location: Birmingham


Return to Help

Who is online

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