Populating unique data from sheet to form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ellipsism
    New Member
    • Jan 2008
    • 6

    Populating unique data from sheet to form

    Hello, I'm wondering if there is an easy way of populating the unique records in an excel column to a listbox or combobox. I am thinking of doing something like
    Code:
        For r = 2 To 128
                With CB_List
                    For n = 0 To .ListCount
                        If .List(n, 0) = Sheets("Testsheet").Cells(r, "U") Then
                            Exit For
                        End If
                    Next n
                    If n = .ListCount + 1 Then
                        .AddItem
                        .ColumnCount = 1
                        .List(.ListCount - 1, 0) = Sheets("Testsheet").Cells(r, "U")
                    End If
    
                End With
        Next r
    Which does not work right now, but will eventually. I just thought there must be a simpler way. Does anyone know if there is such a way?

    Best regards, Johan
  • ubentook
    New Member
    • Dec 2007
    • 58

    #2
    Add the items from the Excel list to a Collection.
    A Collection object will not accept duplicates.
    Then add the contents of the Collection to the listbox.

    Comment

    Working...