ExcelBanter

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

Rebecca

Macros and if statements
 
can I run a macro from an if statement, i.e if this then run macro otherwise do nothing?

Andoni[_14_]

Macros and if statements
 
Yes, Of Course!

try this eg to see:



Sub Eg1()
MsgBox "Hello"
End Sub

Sub Eg2()
MsgBox "Bye-Bye"
End Sub


Sub eg_Total()
If Range("A1") = Range("B1") Then
Call Eg1
Else
Call Eg2
End If
End Su

--
Message posted from http://www.ExcelForum.com


Norman Jones

Macros and if statements
 
Hi Rebecca,

No a macro cannot be run from an if statement.

You could, however, almost certainly get the functionality you want using
an event procedure, If you are not familiar with event procedures, you might
want to look at Chip Pearsons page on the subject:

http://www.cpearson.com/excel/events.htm

In any case, if you care to explain what it is that you would like to
achieve, I am sure that someone will assist you with a suitable solution.


---
Regards,
Norman




"Rebecca" wrote in message
...
can I run a macro from an if statement, i.e if this then run macro

otherwise do nothing?




All times are GMT +1. The time now is 01:34 AM.

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