+ Reply to Thread
Results 1 to 12 of 12

Removing Duplicates in Listboxes or Comboboxes

  1. #1
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Question Removing Duplicates in Listboxes or Comboboxes

    Hi There,

    I'm creating a dyamic sub routine that when placed in a Userform code module and called upon will loop through all controls within the form and remove duplicates from the listboxes or comboboxes.

    i've got 95% of the way but now i just can't seem to delete the item?

    here's what i have so far:

    Please Login or Register  to view this content.
    any help is greatly appreciated folks and thanks for taking the time to read this

    also for some help i craeted one that loops through LB' & CB and orders them

    FYI i used some code from John Walkenbach in this so it's not all my own work:

    Please Login or Register  to view this content.
    Cheers
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    Wouldn't it make more sense to not add the duplicates in the first place?
    Remember what the dormouse said
    Feed your head

  3. #3
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Removing Duplicates in Listboxes or Comboboxes

    Hi Romper,

    Yes it would mate but I use a dynamic named range containing surnames etc to populate the comboxes etc using the tag:

    Please Login or Register  to view this content.
    More than anything i just want this snippet to work so it can be used within any userform etc.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    Have you tried just:
    Please Login or Register  to view this content.
    Note: O is really not a good variable name!

  5. #5
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Removing Duplicates in Listboxes or Comboboxes

    Hi Romper,

    Tried it with no success?

    any reason my O isn't a good variable? (Curiosity really)

    Cheers

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    How clear is:
    Please Login or Register  to view this content.
    at first glance?

    It should work, because that is the syntax (assuming your control is not actually bound to a range). What happened?

  7. #7
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Removing Duplicates in Listboxes or Comboboxes

    I figured you'd say that lol, to eb fair i usually do the bog standard "i" or "n".

    Here's the error i'm getting:
    "Invalid Arguement"
    Attached Files Attached Files

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    Your value of O is too big then. Try this:
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Removing Duplicates in Listboxes or Comboboxes

    Easy Romper,

    this has removed some of the duplicates but not all of them? i've checked the spelling, length and case of all the duplicates it's left and they are all the same so something in there isn't quite right?

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    Can you post a sample showing that? It worked in my (admittedly limited) testing.

  11. #11
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Removing Duplicates in Listboxes or Comboboxes

    of course mate,

    had to can most of the data for DPA but left the first name column in there for you

    cheers for taking the time to help
    Attached Files Attached Files

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Removing Duplicates in Listboxes or Comboboxes

    I was too lazy to figure it out (you were right though!), so I rewrote it instead:
    Please Login or Register  to view this content.

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