Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macros and if statements

can I run a macro from an if statement, i.e if this then run macro otherwise do nothing?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If statements in macros Dan Wood Excel Discussion (Misc queries) 10 December 17th 09 02:48 PM
How can I use wildcards in IF statements and Macros AlanF Excel Discussion (Misc queries) 2 November 22nd 09 11:08 PM
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
How do i start Macros using IF statements? xXx Katie xXx Excel Discussion (Misc queries) 2 August 22nd 05 03:13 PM
True / false statements in Macros RogerNZ Excel Programming 3 June 14th 04 03:13 AM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"