Macros and if statements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

can I run a macro from an if statement, i.e if this then run macro otherwise do nothing?
 
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
 
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 said:
can I run a macro from an if statement, i.e if this then run macro
otherwise do nothing?
 

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