Browsing Markets

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

Moderator: 2020vision

Browsing Markets

Postby negapo » Thu Apr 09, 2009 6:16 pm

Hi,
Can anyone give me a little help. I don't understand anything about VBA and i was trying to browse my quick pick list trying to find certain conditions. (i have to do this in VBA because after a "-1" in cell Q2 B.A. clean all values in that cell).

I have ten worksheets with this code in each one

Private Sub Worksheet_Calculate()
If Range("B16").Value <> "0" Then
Range("Q2").Select
ActiveCell.FormulaR1C1 = "-1"
Else
Range("Q2").FormulaR1C1 = "0.1"
End If
End Sub

If the market conditions are met cell B16 as the value 0.
If only one sheet is logging everything is OK but if i run more than one worksheet i get an error:
"Select Method of Range class failed"

Much appreciate for any help.
negapo
 
Posts: 179
Joined: Thu Mar 19, 2009 1:17 pm
Location: Porto, Portugal

Postby dgs2001 » Thu Apr 09, 2009 6:46 pm

negapo

I'm no expert but the following may help.

Firstly we don't need to select a cell (range) to work on it so E.G.

Code: Select all
Range("Q2").Select
ActiveCell.FormulaR1C1 = "-1"

Becomes
Code: Select all
Range("Q2")="-1"


Secondly we need to stop anything else being done to your sheets while this code is running so in each sheet just after
Code: Select all
Private Sub Worksheet_Calculate()

we put in
Code: Select all
Application.EnableEvents = false

and just before
Code: Select all
End Sub
we put
Code: Select all
Application.EnableEvents = True


So the complete code becomes
Code: Select all

Private Sub Worksheet_Calculate()

Application.EnableEvents = False

If Range("B16").Value <> "0" Then
Range("Q2")= "-1"
Else
Range("Q2") = "0.1"
End If

Application.EnableEvents = True
End Sub


Try this it might work it might not!!

Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby negapo » Thu Apr 09, 2009 7:02 pm

Duncan
Thank you very much for the code and the explanation.
It works fine, now i just have a problem with the synchronization because B.A. jumps two markets without checking the validation of my market conditions, he is two fast :D

By the way, i will use this topic for something related. Does anyone has a strategy for B.A. to loop the quick pick list? I'm searching for market conditions and when it reaches the final market of the list it stops. I have to find a simple way to start the "-2" in cell Q2 when that happens.

Edit:
If the code is insert in
Private Sub Worksheet_Change(ByVal Target As Range)

it works fine :D

Thank you again
negapo
 
Posts: 179
Joined: Thu Mar 19, 2009 1:17 pm
Location: Porto, Portugal

Postby jokerjoe » Thu Apr 09, 2009 10:36 pm

This is a bit written in a bit of a rush, but I wait for at least a couple of refreshes of a new market before actioning any code, I've posted about this somewhere. Key is to maintain a refresh counter, search my posts.

edit: http://gruss-software.co.uk/forum/viewtopic.php?p=16247&highlight=#16247

hope it helps
User avatar
jokerjoe
 
Posts: 122
Joined: Wed May 09, 2007 12:00 pm

Postby negapo » Fri Apr 10, 2009 8:00 pm

jokerjoe
Thanks a lot for sharing. I think that is the best idea to run different code on spreadsheets with delay but I'm having a hard time to adapt it (very very newbie). Your code adjusted to my problem:

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Private MyMarket As String
Private RefreshCount As Long
            If Range("A1").Value = MyMarket Then
                RefreshCount = RefreshCount + 1
            Else
                MyMarket = Range("A1").Value
                RefreshCount = 1
            End If
If RefreshCount > 20 Then

If Range("B17").Value <> "0" Then
Range("Q2") = "-1"
End If
End If
End Sub


Was trying to run the last if just when the current market had been updated at least 20 times. Thanks in advance for any tip.
Edit: My problem is that nothing happens.
negapo
 
Posts: 179
Joined: Thu Mar 19, 2009 1:17 pm
Location: Porto, Portugal

Postby dgs2001 » Sat Apr 11, 2009 9:18 am

Code: Select all
Dim MyMarket as string


This needs to be at the very top above

Private Sub Worksheet_Change(ByVal Target As Range)


Try that

Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby negapo » Sat Apr 11, 2009 7:25 pm

Duncan

Thank you for your suggestion. It was that. I was defining the variable inside the sub so every time the end sub came it cleaned the variables MyMarket and RefreshCount values. I have puted in the top as you said, under the "general" part of the code sheet.
Everything is ok now. I managed to browse the markets and when it reaches the end of the quick list i put a -5 in Q2 to go to the first one of the list. I made this by storing the value of the name of the market and when its the same after a few refreshes it assumes its on the end o the quick pick list.

The only problem i have is that B.A. seems to handle badly the constant loading of markets (i have ten spreadsheets browsing) and brings a message box saying: "Failed to load market, please try again."
Does anyone has this problem?
negapo
 
Posts: 179
Joined: Thu Mar 19, 2009 1:17 pm
Location: Porto, Portugal


Return to Find an Excel developer

Who is online

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