View Single Post
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

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