Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Spooz
 
Posts: n/a
Default 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   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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
show macro security setting in a cell Mark Excel Worksheet Functions 3 March 21st 05 07:53 AM
Macro on cell content Riko Wichmann New Users to Excel 2 March 3rd 05 02:07 PM
How can I get a cell locked if the condition is false? FareedAhmed76 Excel Worksheet Functions 1 February 18th 05 01:49 PM
Problem with IF condition or vector lookup? J-Philippe Excel Worksheet Functions 4 January 15th 05 08:41 PM


All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"