Assign Macros to a dropdown list

G

Guest

I have a dropdown list on an Excel sheet and would like to assign macros to
each of the 14 entries that are in the drowdown menu. I am able to assign a
single macro that runs when clicking on any name in the list but I want to
assign a different macro to each name in the list. Can that be done?
Thanks
 
T

Tom Ogilvy

Not by assinging. In you single macro, you would use/examine the listindex
property and make a decision about which of the 14 macros to call.
 
G

Guest

Thanks for responding Tom. I have no idea what you are suggesting. I
attempted to find the "examine the listindex property" that you suggested but
did not see it. I am new to this type of programming in Excel/Visual Basic so
I forgive my being slow.
Thanks
 
T

Tom Ogilvy

Are you using a dropdown/combobox from the forms toolbar

Are you using a combobox from the control toolbox toolbar

Are you using the list option from Data=>Validation (if so, what is the
earliest version of Excel that will need to load this workbook?)
 
G

Guest

I am using Excel 2003 and that version will be used by everyone viewing the
file. I inserted the dropdown box into the sheet using the forms toolbar.
That is as far as I got except for using the assign macro menu to get a
single macro to function when clicking on any of the names in the dropdown
box.
 
T

Tom Ogilvy

Sub DropDown_Click()
dim drpdwn as DropDown
set drpdwn = ActiveSheet.Dropdowns(Application.Caller)
Select Case drpdwn.ListIndex
Case 0
' no selection, do nothing
Case 1
' Item1 selected
Macro1
Case 2
' item2 selected
Macro20
Case 3
' item3 selected
Macro5
Case 4 to 14
' one of item 4 to 14 selected
Macro2B
End Select
End Sub

as an example.
 
G

Guest

Thanks Tom for your help with this project. I was able to get your code
example to work in my Excel sheet with some editing. In working at this
project I have gained some knowlege at using Visual Basic as well.

Thanks Again for your help
Jeff
 

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