Add Values in a comma separated cell to combobox

K

k3holdings

Hey all,

I have a ComboBox on a Userform that I want to populate with a list of
choices from a single cell. The cell has values like Yes, No, Maybe, I
Don't Know. They are all separated with a comma. Is there a way to do
this?

Right now if I do this

With ComboBox1
.AddItem (The Cell I want)
End With

The ComboBox gets populated with all the cell contents on a single
line.
I would like each string separated by a comma in the cell, to be on a
separate line in the ComboBox.

Any ideas will be appreciated.

Thanks,
Kyle
 
S

Stefi

Try this:
Sub test()
optarray = Split(Range("A1"), ",")
With ActiveSheet.ComboBox1
.Clear
For opt = 0 To UBound(optarray)
.AddItem (optarray(opt))
Next opt
End With
End Sub

Regards,
Stefi


„[email protected]†ezt írta:
 
K

k3holdings

Thank you Stefi for your reply.
That did excactly what I needed it to.

Much Obliged,
Kyle
 

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

Top