+ Reply to Thread
Results 1 to 10 of 10

Get unique values sorted

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Get unique values sorted

    Hello everybody
    I have an ttachment which contains a UDF function that extracts non blank values
    The results in Result sheet
    I want to edit that function to be able to get unique values and to be sorted ..

    Note : I want to deal with the whole rows ..I mean if in A1-B1-C1 (11 - 111 - 1111) and in A19-B19-C19 (11 - 111 - 1111) so the both rows are the same .. when getting unique values one of the rows are to be deleted

    The sort should be based on Column A
    Attached Files Attached Files
    Last edited by YasserKhalil; 01-01-2015 at 03:11 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Get unique values sorted

    UDF

    Use in cell like
    =IFERROR(UniqNonBlank($A$1:$C$19,ROW(A1),COLUMN(A1)),"")
    then copy to the right and down (non array formula, see attached)
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Cool Re: Get unique values sorted

    Here is the code you are looking for.
    I have used a totally different approach i.e. the inbuilt AdvancedFilter Object

    Please Login or Register  to view this content.
    Check the attached file for further instruction.
    Last edited by Vikas_Gautam; 01-01-2015 at 05:02 AM.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Get unique values sorted

    Hi Yasser,

    To get unique, non blank, non error items is an easy job.
    The problem is since Excel VBA doesn't provide internal sorting mechanism inside a function (I mean inside function, not inside procedure like Range.Sort()), so we must provide the sorting function by ourself.
    Here, I give 2 alternatives sorting method : Bubble Sort and QuickSort (QuickSort code provided by CPearson)

    Bubble Sort :
    - Very small code
    - Work faster for small data (about 1 to 100 data will be good)
    - Work faster if the data is has already/almost sorted

    Quick Sort :
    - Big code
    - Work faster for huge data (over 10.000 data)
    - Work faster for unsorted data

    You can read them here :
    http://www.quora.com/Which-is-faster...or-bubble-sort
    http://vinayakgarg.wordpress.com/201...d-bubble-sort/


    So I give you 2 functions :
    - UniqueNonblankSorted() --> using bubble sort
    - UniqueNonblankQSorted() --> using quick sort (QSort code by CPearson)

    Please look at the attached file.
    The long CPearson's QSort Code is located at module CPearson_QSort, so if you want to use the UniqueNonblankQSorted() function in another project, you must also include this module to your project.

    Regards
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  5. #5
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Cool Re: Get unique values sorted

    I forgot consider the sort request in the Post #3, but I have now.
    Here is the code:-
    Please Login or Register  to view this content.
    Check the attached file:-

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Get unique values sorted

    Quote Originally Posted by YasserKhalil View Post
    I want to edit that function to be able to get unique values and to be sorted ..

    The sort should be based on Column A
    Use in cell like
    =IFERROR(UniqNonBlank($A$1:$C$18,1,ROW(A1),COLUMN(A1)),"")
    then copy right and down.
    2nd argument, 1, is the key column for sort.
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Get unique values sorted

    Thanks a lot everybody
    All the solutions are very good
    But I liked Jindon's last post it's fantastic ..
    Just the sort process : How does it work? I tried the argument you told but I didn't notice sort at row 8 and 9 in results?

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Get unique values sorted

    Correction....
    Code should be
    Please Login or Register  to view this content.
    Last edited by jindon; 01-01-2015 at 08:27 AM. Reason: Re edit

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Get unique values sorted

    After revision...
    =UniqNonBlank($A$1:$C$19,1,ROW(A1),COLUMN(A1),1)
    Where 2nd argument is for Sort key col
    Last argument for sort order, 1 for ascending, 0 for descending.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 01-01-2015 at 08:49 AM.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Get unique values sorted

    thanks a lot Mr. jindon
    You are perfect

+ 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. [SOLVED] Summerize unique values from multiple columns / Sorted alphabetically
    By Lacaycer in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-01-2014, 02:40 PM
  2. [SOLVED] Extract Unique Values from Long list and Put in Sorted Order
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-08-2013, 09:10 PM
  3. [SOLVED] Unique distinct alphabetically sorted list
    By atlant15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:03 AM
  4. Sorted List of all Unique strings
    By ElmerS in forum Excel General
    Replies: 2
    Last Post: 04-30-2009, 02:40 PM
  5. Indexing Down Sorted Column to Next Unique Number
    By longfisher in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-02-2007, 07:45 PM

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