tags:

views:

13

answers:

1

I have a combo box in a userform in VBA and want to make the user selection into a variable. IE, I have a combobox with values 1-50 and want to take the number they select and use it as a variable. Thanks.

A: 

You can;

Dim str as String

''always available, what was selected or typed into the box:
str = TheComboBox.Text
msgbox "drop down text: " & str

''for drop-downs, always returns the text of an item:
if (TheComboBox.ListIndex > -1) then
    ''something is selected;
    str = TheComboBox.List(ComboBox1.ListIndex)
    msgbox  "drop down value: " & str
end if
Alex K.