How to select a horse/dog if it is the favourite?

Please post any questions regarding the program here.

Moderator: 2020vision

How to select a horse/dog if it is the favourite?

Postby cjones198 » Wed Oct 21, 2020 2:32 pm

Hi if anyone can help please?

I wish to write a piece of code that goes through column O and selects the favourite based on it being the lowest price or through column P based on it having the most amount of money matched.

and using it as the selection for the rest of the code to refer to (its for autorecording Australian markets and the dogs) which are not listed favourite first.

ive tried the following code
Code: Select all
Sub find_fav()
Dim Largest As Long
    Dim Smallest As Long
    Dim FirstPlace As Range
    Dim LastPlace As Range

    Largest = WorksheetFunction.Max(Range("O5:O25"))
    Smallest = WorksheetFunction.Min(Range("O5:O25"))

    Range("A18").Value = Largest
    Range("A19").Value = Smallest

    Set FirstPlace = Range("O5:O25").Find(what:=Largest, LookAt:=xlWhole)
    Set LastPlace = Range("O5:O25").Find(what:=Smallest, LookAt:=xlWhole)

    Range("B18").Value = FirstPlace.Address
    Range("B19").Value = LastPlace.Address



End Sub

(pieced together from internet research) to find the smallest value and highest value within the range but it only a) rounds to 0 decimal place and b) says run time error 91 object variable or with block variable not set ( but only for the last bit of the code Range("B19").Value = LastPlace.Address
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm

Re: How to select a horse/dog if it is the favourite?

Postby Captain Sensible » Wed Oct 21, 2020 3:36 pm

a) only rounds to 1 decimal because you declared the variable as Long, should be declared as Double if you wanted decimals.

b) run time error 91 usually occurs where the oject doesn't exist, can't see any error from the code you posted up, maybe you need to step through it debugging and checking what values your variables are holding.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Re: How to select a horse/dog if it is the favourite?

Postby cjones198 » Wed Oct 21, 2020 3:52 pm

Thanks Captain!!
cjones198
 
Posts: 102
Joined: Wed Aug 05, 2020 10:02 pm


Return to Help

Who is online

Users browsing this forum: Marx and 33 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.