Combo Box Question

  • Thread starter Thread starter cuz202
  • Start date Start date
C

cuz202

I'm using Excel 2002 and would like to use a combo box (from the Forms
toolbar) to allow a user to easily select one of four macros. I saw
nothing that would indicate that a macro can be assigned to a choice
in a combo box. Can it be done or is there an alternate approach
which accomplishes the same thing.

Thanks
 
I'm using Excel 2002 and would like to use a combo box (from the Forms
toolbar) to allow a user to easily select one of four macros. I saw
nothing that would indicate that a macro can be assigned to a choice
in a combo box. Can it be done or is there an alternate approach
which accomplishes the same thing.

Thanks

By right-clicking on the combobox you can assign a macro to the combobox.
Perhaps you could then capture the events of this combobox. However, a
different solution is using the "ComboBox"-control from the "Control
Toolbox"-toolbar. This control is easily accessed by Visual Basic for
Applications. Again, right-click on the item and click on "View Code".
You'll get taken to the VBE, where you can enter code for a number of
events that are specific to the combobox-control.

HTH,

CoRrRan
 
I put the names of 4 macros (testme1, testme2, testme3, and testme4) in A1:A4
and made that my input range for my dropdown from the Forms toolbar. (Make sure
you don't misspell them!)

Then I put this stuff in a general module:

Option Explicit
Sub testme()

Dim myDD As DropDown
Set myDD = ActiveSheet.DropDowns(Application.Caller)

If myDD.Index <> 0 Then
With myDD
Application.Run .List(.ListIndex)
End With
End If

End Sub
'my test macros
Sub testme1()
MsgBox "testme1"
End Sub
Sub testme2()
MsgBox "testme2"
End Sub
Sub testme3()
MsgBox "testme3"
End Sub
Sub testme4()
MsgBox "testme4"
End Sub

I assigned Testme to the dropdown.
 
Back
Top