VBA help needed

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

Moderator: 2020vision

VBA help needed

Postby Captain Sensible » Wed Nov 23, 2005 10:49 am

Can anyone give me an idots guide to

Worksheet_Calculate()

Now the profit and loss is included in the worksheets I end up with redundant data left on the spreadsheet if the number of runners is less than the number of runners in the previous race when it auto selects markts.

As my calculations use the profit and loss figure i need to clear previous markets data. Some sheets start at B10 some A1 so an idiots guide to resetting data to "" would be useful so I can write any amendments myself.

Someone posted

Private Sub Worksheet_Calculate()
Static MyMarket As Variant
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If [A1].Value = MyMarket Then
GoTo Xit
Else
MyMarket = [A1].Value
Range(Cells(5, 17), Cells(100, 20)).Value = ""
End If
Xit:
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub


But adjusting cell references doesn't seem to work for me
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

OK sorted

Postby Captain Sensible » Wed Nov 23, 2005 11:06 am

Used

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static MyMarket As Variant
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If [A1].Value = MyMarket Then
GoTo Xit
Else
MyMarket = [A1].Value
Range(Cells(5, 17), Cells(100, 20)).Value = ""
End If
Xit:
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub

Instead and for some reason selection by change works fine all the ranges are easy to amend no idea why Worksheet_Calculate() wasn't working
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Ian » Wed Nov 23, 2005 11:12 am

I posted this code on the BF forum ... the bit you need to change is

Range(Cells(5, 17), Cells(100, 20)).Value = ""

Cells(5, 17) means Row 5 Column 17 ie. Q5
Cells(100, 20) means Row 100 Column 20 ie T100

so to extend to range by columns the code should be changed as follows

Range(Cells(5, 17), Cells(100, 22)).Value = ""
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Captain Sensible » Wed Nov 23, 2005 11:16 am

Thanks Ian, I'd figured out the cell references but for some reason it would recalculate.

Using

Private Sub Worksheet_SelectionChange(ByVal Target As Range

works fine so I'll stick with that.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Ian » Wed Nov 23, 2005 11:24 am

I think SelectionChange only works if you physically change the active cell or range so changing the market in BA won't on its own cause the macro to run.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Captain Sensible » Wed Nov 23, 2005 11:47 am

Got it working with

Private Sub Worksheet_Calculate()

no idea why it wouldn't work correctly before.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Recalulation Private Sub Worksheet_Calculate()

Postby markmac1 » Thu Jan 11, 2007 12:07 pm

Is there any trick to get this working in Excel 2000.
I know the procedure works Ok as I have triggered it manually but it doesn't seem to get initiated when the market refreshes.

Thanks

8)
Regards

Markmac1
markmac1
 
Posts: 2
Joined: Sat Jan 06, 2007 11:49 am

Postby GeorgeUK » Thu Jan 11, 2007 1:40 pm

Are there any formulas in your workbook?
this is the only thing that would activate a worksheet_calculate event

If you want a macro to run on each refresh, does worksheet_change not do it?
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby markmac1 » Fri Jan 12, 2007 12:17 pm

George,
I know diddly squat about VBA but i thought the intention of this macro was to clear the "trigger" are of the worksheet when the next race refreshed.
I tried setting up a simple formula which flip flopped the value in a cell on the spreadsheet but it didn't seem to work either.
Regards

Markmac1
markmac1
 
Posts: 2
Joined: Sat Jan 06, 2007 11:49 am


Return to Discussion

Who is online

Users browsing this forum: Bing [Bot] and 39 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.