+ Reply to Thread
Results 1 to 4 of 4

Get unique list of strings

  1. #1
    Registered User
    Join Date
    04-22-2009
    Location
    Boston
    MS-Off Ver
    Excel 2013
    Posts
    68

    Get unique list of strings

    Hi,

    I have 2 arrays of strings.

    Please Login or Register  to view this content.
    I get str1 filled up using external program. I am filling up those here manually.

    Please Login or Register  to view this content.
    The aim of the program is to get unique names.
    Hence the output will be.

    Please Login or Register  to view this content.
    It will be also great to minimize the no. of comparisons as I am dealing with strings of quite a good length.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Get unique list of strings

    Use one array of strings, sort, and delete duplicates?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Get unique list of strings

    Hello kapilrakh,

    This macro will print the your list of unique strings in a single column on a worksheet and sort them in ascending order.
    Please Login or Register  to view this content.
    Example of Using the Macro
    This will copy the list to the Active Sheet. Starting in Cell "A1".
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Get unique list of strings

    Hi kapilrakh

    If you have excel 2007 an easy way to do it is to use an auxilliary range and the Range method RemoveDuplicates.

    Ex.: using column A in the active sheet as auxilliary:

    Please Login or Register  to view this content.

    This funcion receives an array of strings and returns an array with the same size but without duplicates.

    Notice that you don't have to worry with any algorithm.

    Let's test it with the example you posted:

    Please Login or Register  to view this content.
    Remark: I assumed the array index starts at 1.

+ 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