ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   running macros (https://www.excelbanter.com/excel-programming/426980-running-macros.html)

piglaup

running macros
 
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?

FSt1

running macros
 
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

"piglaup" wrote:

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?


Jacob Skaria

running macros
 
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
---------------
Jacob Skaria


"piglaup" wrote:

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?



All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com