ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statements and macros (https://www.excelbanter.com/excel-programming/368033-if-statements-macros.html)

bmorganh

If statements and macros
 
Is it possible for an "if" statement to initiate a macro?

Leith Ross[_684_]

If statements and macros
 

Hello Bmorganh,

in VBA code yes you can initate a macro using a If statement. Jus
substitute the name of your macro for MyMacro in the example. The macr
can be run at anytime in VBA simply by placing the macro's name, and an
arguments required in your code.

Example:
If condition = True Then
Call MyMacro
End If

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=56400


Dave Patrick

If statements and macros
 
Sure

If Range("A1").Value = 1 Then
Range("C1").Interior.ColorIndex = 3
Else
Range("C1").Interior.ColorIndex = 5
End If

(though you wouldn't need a macro for this)

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"bmorganh" wrote:
| Is it possible for an "if" statement to initiate a macro?




All times are GMT +1. The time now is 11:02 AM.

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