ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Values in a comma separated cell to combobox (https://www.excelbanter.com/excel-programming/420729-add-values-comma-separated-cell-combobox.html)

[email protected]

Add Values in a comma separated cell to combobox
 
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

Stefi

Add Values in a comma separated cell to combobox
 
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


ezt *rta:

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


[email protected]

Add Values in a comma separated cell to combobox
 
Thank you Stefi for your reply.
That did excactly what I needed it to.

Much Obliged,
Kyle



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

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