MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Running macro from IF function

Posted by Tom on August 08, 2001 10:10 AM

How can a Macro be run from and IF function?
Something like, IF(xxx),macro 1,macro 2.

Posted by faster on August 08, 2001 11:23 AM

Interesting question. I did it with a function, there
may be a better way. . .

'cell contents

'module contents
Function Test()
Call MyCode
End Function

Sub MyCode()
MsgBox "HI"
End Sub

Posted by steve Lodge on August 09, 2001 4:42 AM

I've tried this function but it doesn't actually call the "test()" function in the module, it just prints "test()" in the cell where the function was placed.
Back to original question can a macro be run from a function?

Posted by Kevin on August 09, 2001 11:02 AM


I tried this and it worked perfectly for me. I would double-check your vb code and make sure that you have it typed exactly as appears in the post. Good luck.