ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.

Kind Regards
 
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
 
Hi,
Thanks for your help. This works. Thanks.
-----Original Message-----
Hi,


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

.
 

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

Back
Top