Hi all
On the Bet angel template spreadsheet, when it is connected, the timer changes each refresh in Cell C3, and I try to run the following Private sub in the "Bet Angel" Sheet:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$3" Then MsgBox "!!!!"
End Sub
Nothing happens. I would've expected it to trigger the message box as the timer is changing every second, but it doesn't. when I manually enter in data in cell C3, it triggers the message box.
I was wondering if anyone could explain why this occurs?
Worksheet Event - Change
My VBA knowledge is sketchy and learned by cannibalising existing routines and trial and error. I seem to recollect a similar problem and the cause seemed to be that you couldn't operate a worksheet change event in the BetAngel sheet. If you do a link to the cell in question from another worksheet, you may find it will work. No guarantees and I'm prepared to be shot down in flames.
Try brackets around the cell address.
If Target.Address = ("$C$3") Then
If you are just targeting a single cell, exclude all other possibilities first, so it would be:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> ("$C$3") Then Exit Sub
Range("G1") = "It Changed!"
End Sub
If Target.Address = ("$C$3") Then
If you are just targeting a single cell, exclude all other possibilities first, so it would be:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> ("$C$3") Then Exit Sub
Range("G1") = "It Changed!"
End Sub
-
- Posts: 136
- Joined: Fri Jul 03, 2009 1:08 am
Tried both of those suggestions, Nigel, however getting the same result as before.
I basically want to avoid using the Worksheet Calculation Event trigger as I want a macro to do recalculation for a particular range of cells and not for the whole workbook.
I basically want to avoid using the Worksheet Calculation Event trigger as I want a macro to do recalculation for a particular range of cells and not for the whole workbook.
-
- Posts: 3140
- Joined: Sun Jan 31, 2010 8:06 pm
I think the change event is firing manually because you're changing the active cell when you hit enter, but simply using If Target.Address = "$C$3" Then MsgBox "!!!!" won't trigger a worksheet change.
Last edited by spreadbetting on Sun Jan 25, 2015 3:36 pm, edited 1 time in total.
-
- Posts: 3140
- Joined: Sun Jan 31, 2010 8:06 pm
Your formula would only work for me manually not automatically, nigel.
Probably best if you say what you're actually trying to do, RideTheLightening, as it's probably only a case of exiting any Worksheet change if your criteria isn't met, you can use VBA to switch off automatic calcualtions and just target certain cells using something like
Range("A1:G20").Calculate
Or even copy data to different parts of the sheet if you want to preserve it.
Probably best if you say what you're actually trying to do, RideTheLightening, as it's probably only a case of exiting any Worksheet change if your criteria isn't met, you can use VBA to switch off automatic calcualtions and just target certain cells using something like
Range("A1:G20").Calculate
Or even copy data to different parts of the sheet if you want to preserve it.
-
- Posts: 136
- Joined: Fri Jul 03, 2009 1:08 am
Thanks Nigel, that works for me on the Betdaq Bet Angel, but not the Betfair one! That is surprising, why would that be?
I do have other code, but not on that Worksheet and it is a Worksheet Calculation and only works between certain times.
I will post a more detailed explanation of what I want to do later, spreadbetting. But thanks for your help in the meantime.
I do have other code, but not on that Worksheet and it is a Worksheet Calculation and only works between certain times.
I will post a more detailed explanation of what I want to do later, spreadbetting. But thanks for your help in the meantime.
-
- Posts: 136
- Joined: Fri Jul 03, 2009 1:08 am
Just to clarify, I have a Private Sub Worksheet_Calculate in Sheet 2 of Bet Angel's excel template. It records Market data each refresh. Each new row is populated with the current refreshed Market data. The Problem is that I need the Calculation setting set to automatic to trigger the Worksheet Calculate event, but of course this leads to all open workbooks being re calculated. As spreadbetting suggested, I could do a calculation on a particular range, but that doesn't trigger the Worksheet calculate event. So I want to try and get the Worksheet_Change event working instead of the worksheet_calculate event.
-
- Posts: 136
- Joined: Fri Jul 03, 2009 1:08 am
Managed to get it sorted. Not entirely sure how I fixed it, could be a couple of reasons, haven't narrowed it down yet.
Anyway, thanks for your help guys.
Anyway, thanks for your help guys.
- rinconpaul
- Posts: 112
- Joined: Wed Dec 03, 2014 10:39 pm
I'd be interested in how you solved this one? I'm having a similar issue with triggering macros based on event change. Specifically when a countdown timer reaches 00:00:00, an IF function changes a cell from "" to "YES", but nothing happens! Not until you hit Enter, F5 or a Trigger button.RideTheLightning wrote:Managed to get it sorted. Not entirely sure how I fixed it, could be a couple of reasons, haven't narrowed it down yet.
Anyway, thanks for your help guys.
As no one else has come forward:
http://www.tradersandpunters.com/data-c ... readsheet/
You might also find the countdown timer on the Bet Angel sheet useful as well.
http://www.tradersandpunters.com/data-c ... readsheet/
You might also find the countdown timer on the Bet Angel sheet useful as well.
-
- Posts: 136
- Joined: Fri Jul 03, 2009 1:08 am
Sorry, didn't notice a reply on this thread till today.rinconpaul wrote:I'd be interested in how you solved this one? I'm having a similar issue with triggering macros based on event change. Specifically when a countdown timer reaches 00:00:00, an IF function changes a cell from "" to "YES", but nothing happens! Not until you hit Enter, F5 or a Trigger button.RideTheLightning wrote:Managed to get it sorted. Not entirely sure how I fixed it, could be a couple of reasons, haven't narrowed it down yet.
Anyway, thanks for your help guys.
Do you have 'automatic Calculation' activated on the formula tab (to get the cell to change to "YES")?
You could put an If statement in your macro doing if countdown timer =00:00:00 then .....