assign a macro to a combo box

G

Guest

Hi

I'm a fairly new user to Macros

I have a worksheet created in XL2003 that contains five buttons created from
the toolbox. Each button successfully runs its own unique macro basically
hiding and showing specific rows. The Macros are caller Sub Macro1( ) to Sub
Macro5( )

Having just come accross Combo boxes where the source data is allocated a
numerical value ie "One"=1, "Two"=2 etc, I would like to allocate Sub Macro1(
) to "One" and Sub Macro2( ) to "Two" etc. so that I can save a lot of space
in my workbook

How can I do this please

Many thanks
 
G

Guest

You can link a cell to your combo box. That cell will then contain the index
of the item selected. Assuming you link to Cell A1 this code should work for
you...

Sub ComboCode()
Select Case Range("A1").Value
Case 1
Call Macro1
Case 2
Call Macro2
Case 3
Call Macro3
Case 4
Call Macro4
Case 5
Call Macro5
End Select
End Sub
 
G

Guest

Hi Jim

Thanks for the reply

This takes me part way to where I would like to get to and is workable for
me. I can just create a Run macro button.

However, my ideal solution would be that in having selected 3 from the combo
box drop down, the selection of that choice would run macro3.

Is this possible or am I asking for too much

Thanks

Dave
 

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