Thread: ComboBox
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default ComboBox

Hi,

I have a comboBox embeded on a worksheet. The comboBox is
from the "Form" menu. It shows four items in the dropdown
list. My problem is how do I assign macros to these four
items, so when one is selected an assigned macro would
run. Also, how do I refer to this comboBox in my codes?
Thanks for your help.


Like this:

- Rightclick the dropdown
- select Attach macro
- hit the New button

Paste in this code between the Sub ... and End Sub lines that are
automatically inserted:

With ActiveSheet.DropDowns(Application.Caller)
Select Case .Value
Case "1"
MsgBox "You selected item 1)"
Case "2"
MsgBox "You selected item 2)"
Case "3"
MsgBox "You selected item 3)"
Case "4"
MsgBox "You selected item 4)"
End Select
End With

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com