0

I really need your help with this as I believe that there is more to this puzzling problem. I am using a basic for loop to grab all of my column values from column A and insert them into my user form combobox (floors).

How can the function below be amended such that it only add the unqiue values 1 time as opposed to just duplicating the column value each and everytime:

enter image description here

Sub tester()

    With Sheets("Office Spaces")

        lRow = Cells(Rows.Count, 1).End(xlUp).row

        For i = 3 To lRow

            If Not IsEmpty(.Cells(i, 1).Value) Then

                Me.floor.AddItem .Cells(i, 1).Value

            End If

        Next i

    End With

End Sub

The desired outcome would look like this: enter image description here

0m3r
  • 12,286
  • 15
  • 35
  • 71
Jason Kelly
  • 2,539
  • 10
  • 43
  • 80
  • You can [populate unique values to an array](https://stackoverflow.com/questions/5890257/populate-unique-values-into-a-vba-array-from-excel#5891317) then move the array to the desired range – cybernetic.nomad Nov 07 '18 at 18:53
  • 1
    Possible duplicate of [Excel VBA adding items to combo box without repeated items](https://stackoverflow.com/questions/28609687/excel-vba-adding-items-to-combo-box-without-repeated-items) – Marcucciboy2 Nov 07 '18 at 19:25
  • The only thing you'd probably have to add to that solution is `Me.floors.clear` above where it loops and adds the items in – Marcucciboy2 Nov 07 '18 at 19:25

0 Answers0