Worksheet Event change macro not working

LetsGo

New Member
Joined
Apr 5, 2011
Messages
2
I am using the standard BetAngel_1 workbook that links BetFair race details directly into a spreadsheet via Bet Angel

I also have 2 other sheets that generate other criteria

My problem is that I have an event change macro in the BetAngel_1 sheet that is supposed to clear a range of cells if K1 changes. K1 is a countdown marker that starts at 0 then changes to 1, 2, 3, etc. up to 17

K1 is linked to a cell in one of the other sheets, eg. =Bet!$B$3

Event code is
----------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = [K1] Then
Range("O9").ClearContents
Range("O11").ClearContents
Range("O13").ClearContents
Range("O15").ClearContents
Range("O17").ClearContents
Range("O19").ClearContents
Range("O21").ClearContents
Range("O23").ClearContents
Range("O25").ClearContents
End If
Application.EnableEvents = True
End Sub
-------------------------------------------------

But it is not working presumably because the Event macro is only triggered when a user changes a cell but not when the value is the result is a formula calculation. However it should work if the result is from VBA code

So my question is how can I change cell k1 to be VBA code

Thanks in advance
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If range("K1").value= 0 and target.range="B3" Then     '<----- countdown value
        Application.EnableEvents = False
        for row = 9 to 25 step 2
            cells(row,"O").value=""
        next row
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
Thanks very much for your reply

Problem is that cell B3 is in another sheet named Bet not in the BetAngel_1 sheet so it is throwing a compile errr

What happens is that cell K1 in BetAngel_1 sheet changes from 0 through to 17 so I need the Event Change to trigger each time this value changes

Your advice much appreciated
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top