ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox (https://www.excelbanter.com/excel-programming/301024-combobox.html)

No Name

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.

Kind Regards

Jan Karel Pieterse

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


No Name

ComboBox
 
Hi,
Thanks for your help. This works. Thanks.

-----Original Message-----
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

.



All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com