Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Avoiding duplicates in a combobox (Office XP (Excel 2002))

    I've written code that scans through a worksheet and selectively adds data to a combobox based on a set of conditions that I won't bore you with. I don't want there to be any duplicates in the combobox, and ideally I'd like it to be sorted. Does anyone know of a way to:
    (a) Check the existing values in the combobox so as to avoid repetition
    ([img]/forums/images/smilies/cool.gif[/img] Sort the list afterwards

    As usual, thanks in advance!
    Waggers
    If at first you do succeed, you've probably missed something.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Avoiding duplicates in a combobox (Office XP (Excel 2002))

    As your code searches through the worksheet for the items to put into the combobox, insert the items into an array instead of into the combobox. Each time you go to insert a new item into the array, search the array to see if it is already there. Then sort the array and put the items from the array into the combobox. There is code in <!post=This Post,373145>This Post<!/post> that shows how to sort an array.
    Legare Coleman

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Avoiding duplicates in a combobox (Office XP (Excel 2002))

    John Walkenbach has a tip/trick to fill a listbox with a unique sorted list taht could be easily modified.

    Steve

  4. #4
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Avoiding duplicates in a combobox (Office XP (Excel 2002))

    Thanks - got it sussed now.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

Posting Permissions

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