Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Choose a macro from within a macro

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Choose a macro from within a macro

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Choose a macro from within a macro

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
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
Choose Which Macro to use SteveT Excel Programming 0 April 6th 07 05:58 PM
CHOOSE TO STOP A MACRO OR NOT Alex Martins[_2_] Excel Programming 8 September 27th 05 11:59 PM
Help with macro to choose printer Wind54Surfer New Users to Excel 2 December 21st 04 12:09 AM
How do I set up macro in VBA to choose worksheets? K Excel Programming 3 November 12th 04 09:00 PM
Choose Function Macro Jim[_31_] Excel Programming 2 April 14th 04 12:36 PM


All times are GMT +1. The time now is 04:06 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"