+ Reply to Thread
Results 1 to 3 of 3

Thread: Delete duplicate entries in a list

  1. #1
    Registered User
    Join Date
    03-17-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    64

    Delete duplicate entries in a list

    This seems to be an often asked question but I am not finding an answer that really helps. I have a list which has a bunch of entries which duplicate many times. What I want to do is to list all the unique values in a combobox. I have the list into the combobox using:

    cbo.list=sheet(1).range(C3:C500).value
    No fuss. Now I want to go through the list and remove the duplicates. But how?

    I do not want to do it on the sheet... I know I can use worksheet functions and transplant the unique values in my first range, to another location on the sheet and then use that as the source for my list. To me, that is messy. So is the above possible? Am I going the wrong way and do I want to cycle through my range and add values unless they equal a value already existing in the list?

    Many thanks for your time

    Adam

  2. #2
    Valued Forum Contributor MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    888

    Re: Delete duplicate entries in a list

    Try this:-
    Private Sub UserForm_Initialize()
    Dim Rng As Range, Dn As Range
    Set Rng = Range(Range("C1"), Range("C" & rows.Count).End(xlUp))
    With CreateObject("scripting.dictionary")
    .CompareMode = vbTextCompare
        For Each Dn In Rng
            .Item(Dn.value) = Dn.value
        Next
    Me.ComboBox1.List = Application.Transpose(.keys)
    End With
    End Sub
    Regards Mick

  3. #3
    Registered User
    Join Date
    03-17-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: Delete duplicate entries in a list

    Thanks Mick,

    That is pretty much the same as I came up with but with a few little extras that make it better (I forgot to get it to just go to the row count).

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0