+ Reply to Thread
Results 1 to 36 of 36

Remove duplicates and sort array

Hybrid View

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Most efficient way to remove duplicates and sort array

    Hi Richard,

    Sorry I should have been more clear about the source of my array. It is a string converted into an array, actually two strings.

      ' Create arrays from strings
        Arr1 = Split(S1, " ")
        Arr2 = Split(S2, " ")
    
      ' Create one (common) array from the two arrays
        Arr3 = Split(Join(Arr1, "|") & "|" & Join(Arr2, "|"), "|")
        
      ' Remove duplicates from arrays
      '*
      '*
      '* Not coded yet
      '*
      '*
      '*
    What I am doing is comparing the two strings for similarities but there is no reason to go through repeated words since they will either be found or not.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Most efficient way to remove duplicates and sort array

    Hi,

    Does Chip Pearson's article http://www.cpearson.com/excel/distinctvalues.aspx help.

    I'm sure what you want is in there somewhere.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  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: Most efficient way to remove duplicates and sort array

    Hello Ahmed,

    I think a better approach would to be to use a Dictionary object. You can easily create a 1-D array of unique values. You could also do this with a Collection object. I prefer the Dictionary object as you can test if an element already exists without generating an error. If you need help coding this, let me know.
    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!)

+ 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