Home |
Search |
Today's Posts |
#1
|
|||
|
|||
How to evoke a macro from a cell condition?
I would like to run a macro automatically bqased upon a change in a
particular cell's condition. As an example: Cell A1 contains the following formula: =if(b2b4,"Sell",0) If A1 = "Sell", I would like to automatically run a macro. Is this possible? If not, can I automatically run a macro from a formula? Any help will be greatly appreciated. Paul |
#2
|
|||
|
|||
You cannot run a macro from a function, but you can run code on a change in
a cell, but you would need to test B2 and B4 here, A1 will not trigger a change Private Sub Worksheet_Change(ByVal target As Range) Dim iPos As Long On Error GoTo ws_exit: Application.EnableEvents = False With target If .Address = "$B$2" Or .Address = "$B$4" Then If Me.Range("B2").Value Me.Range("B4").Value Then 'your code here End If End If End With ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "Spooz" wrote in message ... I would like to run a macro automatically bqased upon a change in a particular cell's condition. As an example: Cell A1 contains the following formula: =if(b2b4,"Sell",0) If A1 = "Sell", I would like to automatically run a macro. Is this possible? If not, can I automatically run a macro from a formula? Any help will be greatly appreciated. Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copying cell names | Excel Discussion (Misc queries) | |||
show macro security setting in a cell | Excel Worksheet Functions | |||
Macro on cell content | New Users to Excel | |||
How can I get a cell locked if the condition is false? | Excel Worksheet Functions | |||
Problem with IF condition or vector lookup? | Excel Worksheet Functions |