Launch a macro with drop down list

O

One-Leg

Hello

I have a dropdown (done using the DATA/VALIDATION menu) in which I have 5
options:

1- All Seasons
2- Winter
3- Spring
4- Summer
5- Fall

I have created 5 macros that will hide rows/columns depending on the
selection.

Now, how can I assign a macro to each options in the drop down?
 
J

JCS

Hi,

I don't think you can accomplish what you wish with Data Validation but by
creating a Combo Box (Forms toolbar - Excel 2003) you should be able to do
what you are asking. You create the Combo Box and then assign the Combo Box
to a macro that would look something like the following:

Sub Seasons()
Dim Selection as Variant
Selection=range("a1").value
Select Case Selection
Case 1
All Seasons
Case 2
Winter
Case 3
Spring
Case 4
Summer
Case Else
Fall
End Select

The Combo Box assigns a number to each item on your list. 1 = All
Seasons, 2 = Winter and so on. This code should reside in the same module
as your other code. Good Luck! If this helps, please press Yes.

JCS
 
J

JCS

Hi,

Forgt to end my code with an End Sub. The Combo Box in effect is similar to
the Data Validation capability. You may have to research it a little, but is
very easy to set up.

JCS
 

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

Top