+ Reply to Thread
Results 1 to 12 of 12

Remove Duplicated items in combo box

  1. #1
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Question Remove Duplicated items in combo box

    i have a combo box in a form from a list of customers

    eg

    Aston Martin
    BMW
    BMW
    Jaguar
    Jaguar

    ect.

    i want to remove the duplicated entries

    so out of the 4 id have

    Aston Martin
    BMW
    Jaguar

    the reason for this is that there maybe more than 1 contact in any particular company.

    then i want a seperate combobox with all the contacts fot the selected company in it

    this will in turn fill in my form
    but i think i can do that bit

    hope you guys can help
    I dont like to use code i dont understand
    it makes it hard to use in other situations
    so please try to be as clear and patent as possible with me

    Criticism is welcomed

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Hi, I think the answer is not to remove the duplicates but instead only to insert unique entries.

    Code you post the code which populates your combobox?

  3. #3
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    hmm ok that sounds good

    thats the kinda thing i ment
    (not too good with words lol)

    Please Login or Register  to view this content.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning FRIEL

    John Walkenbach provides a solution to this on his site here. The code supplied also puts all the items in alphabetical order as well, but you can strip this out if you want. I find that using Collection objects are an excellent (and rapid) way of removing duplicates from an array as it doesn't require multiple looping. There is also a demonstration workbook to download.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    thanks ill go check it out and ill let you know how it goes

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    How's this?
    Please Login or Register  to view this content.
    I used column P (fairly arbitrarily) to create a unique filter of column A which I then used as rowsource for your combobox.

    HTH
    Last edited by Cheeky Charlie; 08-27-2008 at 05:40 AM. Reason: code tags

  7. #7
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    used this
    Please Login or Register  to view this content.
    any ideas on how to do the second part??

    i need to say select bmw
    and for a second combo box to have the different contacts in it

    i think this is going to be the hard bit

  8. #8
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi FRIEL

    Have a look at this workbook with an example userform. I have only done it very simply, so no doubt there are going to be some changes needed, but hopefully it will point you in the right direction.

    HTH

    DominicB
    Attached Files Attached Files

  9. #9
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    yea thats good ive played with it n got it to go with what i need
    thanks allot

    is there a way to reference to a row that the second (contact) value comes from??

    as i have numbers and emails on the same row i want to fill in on the form into textboxes

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi FRIEL

    I'd probably stick with the little table, and have a seperate table that lists all your contacts vertically, and their contact details going across. You can read the contents of the combobox like so :
    Please Login or Register  to view this content.
    and then perhaps retrieve all the pertinent information using VLookUp.

    HTH

    DominicB

  11. #11
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    thanks guys!!

    i used this
    to use find the row

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-03-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Remove Duplicated items in combo box

    Quote Originally Posted by Cheeky Charlie View Post
    How's this?
    Please Login or Register  to view this content.
    I used column P (fairly arbitrarily) to create a unique filter of column A which I then used as rowsource for your combobox.

    HTH
    Superb Code Worked Really well for me

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Inputting items into a Combo Box
    By Zboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2008, 12:25 AM
  2. Combo Box - Display Unique Items in List
    By Gary S in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2007, 11:15 AM
  3. Adding same items to more than one combo box
    By SOS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2007, 07:18 AM
  4. How to reset the combo boxes (remove selected values)
    By Richard Flame in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-11-2007, 02:29 PM
  5. remove items from list box (sorry it`s a bit long)
    By bahadirakcan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2006, 08:11 AM

Tags for this Thread

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.6.0 RC 1