Can you call a macro as in an IF statement

  • Thread starter Thread starter kls
  • Start date Start date
K

kls

As the subject implies, I want to know if I can call a macro as a result
of true logic in an IF statement. If not, how do you go about calling a
macro as a result of conditional statements?
 
A macro can only be called with a macro
sub gg()
if range("a1")=1 then call mymacro
end sub
 
in VBA

If condition then
mymacro
End if

in A worksheet cell, create a userdefined function

=if(condition,Trigger(),"")

Public Function Trigger()
Trigger = "ABCD"
End Function

however, Trigger can only return a value. It can not change other aspects of
the worksheet.

If you need to do things like that, use the calculate or the change event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top