user3538102
user3538102

Reputation: 171

Add specific cells to a combobox

I am trying to add values that are within two distinct cells to my combobox and I cant seem to get it to work! I know that I can populate a range of cells into my combo box:

Me.ComboBox3.List = Sheets("Sheet1").Range("C917:C927").Value

But how would I add c2, c4, c6 to a combobox?

Upvotes: 0

Views: 5309

Answers (1)

SickDimension
SickDimension

Reputation: 912

Hi you need to use for each to loop trough the data and add items to the combo box

Dim c As Range
For Each c In Sheets("Sheet1").Range("C2,C4,C6")
    Me.ComboBox3.AddItem c.Value
Next

To remove values use

For n = Me.ComboBox3.ListCount - 1 To 0 Step -1
    Me.ComboBox3.RemoveItem n
Next n

Upvotes: 1

Related Questions