ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can you call a macro as in an IF statement (https://www.excelbanter.com/excel-programming/309648-can-you-call-macro-if-statement.html)

kls[_2_]

Can you call a macro as in an IF statement
 


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?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Don Guillett[_4_]

Can you call a macro as in an IF statement
 
A macro can only be called with a macro
sub gg()
if range("a1")=1 then call mymacro
end sub

--
Don Guillett
SalesAid Software

"kls" wrote in message
...


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?

*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Tom Ogilvy

Can you call a macro as in an IF statement
 
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.

--
regards,
tom Ogilvy

"kls" wrote in message
...


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?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 03:47 AM.

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