running macros

P

piglaup

Can a macro be run from within a formula?
I would like to run macro A if a cell contains 0 or macro B if that cell
contains anything else.
I know how to setup the NOT formula, but how do you program arguments to get
the macros to run? Is there a way to do that?
 
F

FSt1

hi.
short answer....no.
you can write functions in vba that the cell can call but these functions
return value and cannot perform actions.
you might be able to use the worksheet change event to fire a macro but only
if the value in the cell is changed manually. it will not fire with a
formula change.
There is the calculation event but that would probable fire your macro every
time the sheet recalculated. (eeee!)
so if you could provide a bit more info as to what your are trying to do,
someone might be able to suggest a alternative course of actions.

Regards
FSt1
 
J

Jacob Skaria

You can use the Workbook_SheetCalculate event or Workbook_SheetChange event
to check the value and call the appropriate macro


If this post helps click Yes
 
Top