PDA

View Full Version : Can I use IF function and run a macro?



dilipramadas
08-25-2010, 01:29 AM
I'm trying to use IF function in an excel sheet to run a Macro. Can this be done? I've been told its not possible.:hi:

Simon Lloyd
08-25-2010, 02:04 AM
It's possible to run a macro dependant on a cell value using the worksheet event.

Aussiebear
08-25-2010, 02:05 AM
Its my belief that a function returns a value and not an instruction. Are you sure you are not confusing the difference between an If Function and an If Statement?

Bob Phillips
08-25-2010, 02:21 AM
It is possible to call a macro from the UDF is triggered, but that macro cannot change any data on the sheet directly, just as the UDF cannot.

Simon Lloyd
08-25-2010, 05:05 AM
Its my belief that a function returns a value and not an instruction. Are you sure you are not confusing the difference between an If Function and an If Statement?I assumed, because the OP metioned "IF function in an excel sheet" that he meant a worksheet function rather than meaning VBA :think:

Zack Barresse
08-25-2010, 06:15 AM
...just as the UDF cannot.
:devil2:

dilipramadas
08-25-2010, 08:26 AM
Thanks for the replies. :)
It didn't work with any formula. so we used VBA to solve the prob. i'll post the code tomorrow.
we used the call option. which worked like a trigger. :devil2: