is this possible.

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

Moderator: 2020vision

is this possible.

Postby robcpettit » Fri Mar 17, 2006 11:00 pm

Hi all. I have a question and wil try to ask as clearly as possible but I can see Im going to get tongue tide. Here goes. Im opening up one instance of excel with 2 workbooks, call them A & B. In A im logging current prices. Using worksheet change method, on each refresh I take the data for each horse and put into sheet 2, jiggle with the figures etc. Ounce thats done I have graphs in B linked to certain data in A/sheet 2. This works well anough for me as long as A has focus, If i inadvertantly click on B then debug error apears. Thats fine. Now my question, when Im using excel I have it open in such away that I see only B/the graphs and BA beside it. When certain criteria is met I trade. Is it possible under each graph in B to eather have a button or cell I can click wich will send a back bet, then a lay bet offset by one tick. The problem as I see it is not sending the bet, but clicking anywere on B will give it focus therefore stopping A from functioning. I thought about doing this from A but as thats constantly flicking between worksheets that would be difficult. I dont want to go down the trigger route, because my criteria needs human judgement. I hope this makes sense.
Regards Robert
robcpettit
 
Posts: 35
Joined: Thu Feb 23, 2006 9:22 am

Postby GeorgeUK » Fri Mar 17, 2006 11:52 pm

Can't really say without seeing the code, but it sounds like you need to reference the workbook.

Instead of saying If activeworkbook... you will need to say if workbooks("A")...

It sounds as though this is the problem as when the other workbook (B) becomes active, it may not havethe same layout as A and so the debug errors appear. It may be looking for data which is not in B or of the wrong type.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby Mitch » Sat Mar 18, 2006 5:04 am

That sounds like what would be happening if the code is in a module. As far as I know you can either change all the references to have Workbooks("A"). in front of it as George says, or you could put the code in the workbook code sheet. I think that makes the code refer to the workbook it's in, I know it works with worksheet code.

If you're going down the first route it might be easier to use something like 'Dim wbA as workbook' in the declarations then have wb1. in front of all the references to cells or ranges.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby robcpettit » Sat Mar 18, 2006 9:59 am

Thankyou both for your replys. In workbook A Ive got
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("a1") = "" Then
Exit Sub
End If
Application.ScreenUpdating = False
Application.EnableEvents = False
Update
Application.ScreenUpdating = True
End Sub , in the worksheet, and 'update' is in a module were all the work is done. Would I be better moving this to the worksheet. With B basically I started with a blank sheet, created graphs, though the wizard and clicked the required cells in A. Where you advise to reference the workbook, do you meen in the graphs themselves.
Regards Robert
robcpettit
 
Posts: 35
Joined: Thu Feb 23, 2006 9:22 am

Postby Mitch » Sat Mar 18, 2006 1:10 pm

Not in the graphs, in the module code. If your code acts upon workbookA, and the problem is happening when you are looking at workbookB (with the graphs in) as I understand it.

If you want to refer to whether or not the event is 'In-Play' you would write something like 'If Range("E2") = "In Play" Then.....'
That's fine if you are looking at the workbook that BA sends info to, but when you look at workbookB with the graphs in, vba then takes your above line and looks at E2 in the wrong book because it assumes that it should use the active workbook if not told otherwise.

If you changed my example line above to 'If Workbooks("A").Range("E2") = "In Play" Then.....'
then you could look at whichever workbook you wanted to and the code would always work on workbookA.

I hope that makes some kind of sense, I confuse myself sometimes. :lol:
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby robcpettit » Sat Mar 18, 2006 2:23 pm

Mitch, thanks for the reply. I see what your saying now. To do anything with A from B(charts), I need to reference A in my code. If I had a button on B under a graph, with relevent code (when clicked, back), how do I prevent the code in worksheet on A from stopping and showing vba. Can I use on error resume. That doesnt make sense does it. Ok, sorry if Im repeating this. At the momment I open exel, choose workbook charts(B) first, then workbook Runners(A) second. This gives Runners the focus. The workbooks are arranged as tiled. I open BA and place over Runners, now I see charts and BA, and away I go. If I was to click on Charts, Runners looses focus, stops and opens vba. Is there away to tell it to keep going whatever. In the meen time I trying the Charts in word to see if this helps. Ive tried 2 instances of Excel and the same happens.
Regards Robert
robcpettit
 
Posts: 35
Joined: Thu Feb 23, 2006 9:22 am

Postby GeorgeUK » Sat Mar 18, 2006 4:07 pm

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("a1") = "" Then
Exit Sub
End If
Application.ScreenUpdating = False
Application.EnableEvents = False
Update
Application.ScreenUpdating = True
End Sub


So basically your code is saying:
If workbook A cell A1 is blank, exit
otherwise
turn off screenupdating and enable-events
then call macro "update"
("update" macro will run)
screenupdating turned back on

enable-events not turned back on?????

does the "update" macro specify what workbook it is to work with?
If not, it will work with whatever workbook is active at that time.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby Mitch » Sat Mar 18, 2006 4:45 pm

robcpettit wrote:Mitch, thanks for the reply. I see what your saying now. To do anything with A from B(charts), I need to reference A in my code. If I had a button on B under a graph, with relevent code (when clicked, back), how do I prevent the code in worksheet on A from stopping and showing vba. Can I use on error resume. That doesnt make sense does it. Ok, sorry if Im repeating this. At the momment I open exel, choose workbook charts(B) first, then workbook Runners(A) second. This gives Runners the focus. The workbooks are arranged as tiled. I open BA and place over Runners, now I see charts and BA, and away I go. If I was to click on Charts, Runners looses focus, stops and opens vba. Is there away to tell it to keep going whatever. In the meen time I trying the Charts in word to see if this helps. Ive tried 2 instances of Excel and the same happens.
Regards Robert


Sorry Rob, I'm not sure what you're saying. When you say it "opens vba" do you mean that you get an error and the code window opens in debug mode? If so, then if you put Workbooks("Runners"). before all references that should work on the Runners workbook it should sort it out.

Or (I think) you could cut and paste the update code in the same window as the worksheet_change code.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby robcpettit » Sat Mar 18, 2006 6:22 pm

Thanks again for your replys, I enable the events again in the module. Im not referencing the workbook in my module, So i think what happens is when I click on another worbook, the code looks for the data, but ofcourse it not there, therefore the bug window opens. Ill change my module to ref the workbook, just waiting for racing to finish.
Regards Robert
robcpettit
 
Posts: 35
Joined: Thu Feb 23, 2006 9:22 am


Return to Discussion

Who is online

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