[mso] Re: Using IF to select Macro command to carry out? Possible?
- From: Wilson Baptista Junior <wilson@xxxxxxxxxx>
- To: mso@xxxxxxxxxxxxx
- Date: Tue, 17 May 2005 22:00:46 -0300
Hi Robert,
IMHO you will have to call the macros from VBA (inside another
macro). One command you could use would be the Select Case command;
you set a variable (for example, WhichMacro) to the value of cell A6,
then the macro to run is chosen by code like this:
Sub ChooseMacroToRun ()
WhichMacro.value = Range("A6").value
Select Case WhichMacro
Case 1
Run(FirstTrip)
Case 2
Run(SecondTrip)
Case 3
Run(ThirdTrip)
Case 4
Run(FourthTrip)
Case 5
Run(FifthTrip)
Case 6
Run(SixthTrip)
Case 7
Run(SeventhTrip)
Case Else
Do whatever you must do when the value is not from 1 to 7
End Select
End Sub
Now, to trigger the macro, you can assign it to a button for the user
to click, or have it run automatically whenever the value of cell A6
changes (for this, take a look at the Worksheet_SelectionChange event
in Excel Help).
Wilson
At 17:11 17/5/2005,Robert Carneal wrote:
>In Excel 2000, say I have five macro commands. I will call them Firsttrip,
>Secondtrip, Thirdtrip, Fourthtrip, Fifthtrip, SixthTrip, SeventhTrip,
>WrongTrip
>
>This is illegal in Excel, but please bear with me:
>
>A6=4
>=Choose(A6, Firsttrip, Secondtrip, Thirdtrip, Fourthtrip, Fifthtrip,
>SixthTrip, SeventhTrip)
>
>So whenever A6 is 4, run the macro FourthTrip. Possible? I can use Choose
>with values and formulas, but what about macros?
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx
To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in
the subject line.
Or, visit the group's homepage and use the dropdown menu. This will also allow
you to change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso
To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with
instructions. Once you are a member of the files group, you can go here to
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
- Follow-Ups:
- [mso] Re: Using IF to select Macro command to carry out? Possible?
- From: Robert Carneal
- References:
- [mso] formula explanation needed
- From: Clint Graham
- [mso] Using IF to select Macro command to carry out? Possible?
- From: Robert Carneal
Other related posts:
- » [mso] Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- » [mso] Re: Using IF to select Macro command to carry out? Possible?
- [mso] Re: Using IF to select Macro command to carry out? Possible?
- From: Robert Carneal
- [mso] formula explanation needed
- From: Clint Graham
- [mso] Using IF to select Macro command to carry out? Possible?
- From: Robert Carneal