PC Review


Reply
Thread Tools Rate Thread

Choose a macro from within a macro

 
 
=?Utf-8?B?RmVsaWNpdHkgU2hhZ3dlbGw=?=
Guest
Posts: n/a
 
      19th Jun 2007
I need to write a macro which will choose one of two macros to run, based
upon the value in a single cell. The value in the single cell could be
either numeric or text.

In other words,

IF cell value = x, Application.Run"Macro1", ELSE Application.Run "Macro2".

But I just don't know how to write the proper code for this. Any clues?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      19th Jun 2007
Try this:-

Sub ordinate()
x = 6
If Cells(1, 1).Value = x Then
macro1
Else
macro2
End If
End Sub

Sub macro1()
MsgBox ("Macro1 running")
End Sub

Sub macro2()
MsgBox ("Macro2 running")
End Sub

"Felicity Shagwell" wrote:

> I need to write a macro which will choose one of two macros to run, based
> upon the value in a single cell. The value in the single cell could be
> either numeric or text.
>
> In other words,
>
> IF cell value = x, Application.Run"Macro1", ELSE Application.Run "Macro2".
>
> But I just don't know how to write the proper code for this. Any clues?

 
Reply With Quote
 
=?Utf-8?B?RmVsaWNpdHkgU2hhZ3dlbGw=?=
Guest
Posts: n/a
 
      19th Jun 2007
Hey Mike,

Thanks for that!

"Mike H" wrote:

> Try this:-
>
> Sub ordinate()
> x = 6
> If Cells(1, 1).Value = x Then
> macro1
> Else
> macro2
> End If
> End Sub
>
> Sub macro1()
> MsgBox ("Macro1 running")
> End Sub
>
> Sub macro2()
> MsgBox ("Macro2 running")
> End Sub
>
> "Felicity Shagwell" wrote:
>
> > I need to write a macro which will choose one of two macros to run, based
> > upon the value in a single cell. The value in the single cell could be
> > either numeric or text.
> >
> > In other words,
> >
> > IF cell value = x, Application.Run"Macro1", ELSE Application.Run "Macro2".
> >
> > But I just don't know how to write the proper code for this. Any clues?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choose Which Macro to use =?Utf-8?B?U3RldmVU?= Microsoft Excel Programming 0 6th Apr 2007 05:58 PM
Macro to choose a macro Alec H Microsoft Excel Misc 4 3rd Mar 2006 05:52 PM
CHOOSE TO STOP A MACRO OR NOT =?Utf-8?B?QWxleCBNYXJ0aW5z?= Microsoft Excel Programming 8 27th Sep 2005 11:59 PM
Choose from within a Macro Gerrym Microsoft Access Macros 6 21st Dec 2004 10:47 AM
Choose Function Macro =?Utf-8?B?Smlt?= Microsoft Excel Programming 2 14th Apr 2004 12:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:26 AM.