macros and formulae


Posted by Steve on November 13, 2001 6:18 AM

Can a macro be run from within a formula - eg as part of an IF statement?

Posted by Juan Pablo on November 13, 2001 7:11 AM

Not *directly* as in

=IF(A1=1,Macro1,"")

but you could use the
Worksheet_Change()
or
Worksheet_Calculate()
events to do what you're looking for... i.e.

If Range("A1") = 1 then
Macro1
End If

Juan Pablo



Posted by Rick E on November 13, 2001 7:34 AM

You can define a Function which can have all kinds of code in it, even MsgBox displays, etc. but that cell will only be able to have the output of that function.