Run a Macro When Loading a New Market

Please post any questions regarding the program here.

Moderator: 2020vision

Run a Macro When Loading a New Market

Postby Steve Voltage » Tue Mar 09, 2010 11:21 pm

I have a macro called Macro2 :roll: how is it possible to run this macro every time i load a new market please?
Steve Voltage
 

Postby Captain Sensible » Wed Mar 10, 2010 12:17 am

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


insert macro coding here


End If
Xit:
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Steve Voltage » Wed Mar 10, 2010 10:24 pm

Thanks Captain :)
Steve Voltage
 

Postby Steve Voltage » Thu Mar 11, 2010 9:21 pm

Next question :roll: the code below works when the cells are manually changed but not when linked to excel. is there a simple answer to this?

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)

For i = 1 To 3

If Target.Row = i And Target.Column = 1 Then
Cells(i, 2) = Cells(i, 2) + 1
End If
Next i
End Sub
Steve Voltage
 

Postby Steve Voltage » Fri Mar 12, 2010 4:43 pm

anybody? :(
Steve Voltage
 

Postby Ian » Fri Mar 12, 2010 4:52 pm

What do you mean by "linked to excel" - it is excel ?
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Steve Voltage » Fri Mar 12, 2010 4:56 pm

Ian wrote:What do you mean by "linked to excel" - it is excel ?


I mean linked to Betting Assistant, sorry :oops:
Steve Voltage
 

Postby Ian » Fri Mar 12, 2010 5:26 pm

I think you'll have to explain what you are trying to do.

A1 contains the market name - so will only change occasionally.
A2 & A3 contains constants which will never change.

And you are incrementing B2 and B3 but these are updated at
every refresh in any case.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby knot » Fri Mar 12, 2010 5:47 pm

I think you need to change

Private Sub Worksheet_Calculate()

for

Private Sub Worksheet_Change()
knot
 
Posts: 196
Joined: Sun Feb 04, 2007 9:51 pm
Location: leicester

Postby Ian » Fri Mar 12, 2010 5:54 pm

knot wrote:I think you need to change

Private Sub Worksheet_Calculate()

for

Private Sub Worksheet_Change()



I don't think so because he is trying to determine which cells
have been changed.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby osknows » Fri Mar 12, 2010 9:18 pm

BA does 2 types of refreshes so the range object Target returns a different row/column value on each refresh each time. eg

1. Target.Row = 1 and Target.Column = 1
2. Target.Row = 5 and Target.Column = 20

Therefore your code will only run If Target.Row = i And Target.Column = 1

try this and you'll see the returned values on each refresh

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)

MsgBox (Target.Row & Chr(10) & Target.Column)

End Sub
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am


Return to Help

Who is online

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