Closed Thread
Results 1 to 14 of 14

Non Array Formula to pull unique values and sort in a range

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Non Array Formula to pull unique values and sort in a range

    Looking for non-array formula to pull values unique values in a range that has duplicate values and then sort. Do not want to use an array formula as the range has over 4,000 values. Values in A2:A8000.

    Thanks

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Non Array Formula to pull unique values and sort in a range

    Are the values text or numeric?

    One way to pull unique values without an array formula is to use a helper column (e.g. column H), with a formula like this in H2:

    =IF(COUNTIF(A$2:A2,A2)=1,MAX(H$1:H1)+1,"-")

    That will give sequential numbers down column H for the first occurrence of a value in column A, so you can pick out those unique values using a formula like this:

    =IFERROR(INDEX(A:A,MATCH(ROWS($1:1),H:H,0)),"")

    Copy this down until you start to get blanks.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Non Array Formula to pull unique values and sort in a range

    Pete_UK: formula works like a charm. Need a non-array formula to sort the values in ascending order.

    Is there a way this formula =IFERROR(INDEX(A:A,MATCH(ROWS($1:1),H:H,0)),"") could be modified to start from =IFERROR(INDEX(A2:A8000,MATCH(ROWS($1:1),H2:H8000,0)),"")?

    Thanks
    Last edited by bjnockle; 10-23-2016 at 01:34 PM.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Non Array Formula to pull unique values and sort in a range

    Quote Originally Posted by bjnockle View Post
    Is there a way this formula ... could be modified to start from =IFERROR(INDEX(A2:A8000,MATCH(ROWS($1:1),H2:H8000,0)),"")...
    Yes, but you will need to anchor the row references using the $ symbol, like this:

    =IFERROR(INDEX(A$2:A$8000,MATCH(ROWS($1:1),H$2:H$8000,0)),"")

    As for sorting, you didn't answer the question about whether the data values are text or numeric.

    Hope this helps.

    Pete

  5. #5
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Non Array Formula to pull unique values and sort in a range

    Pete_UK: As for sorting, the data values are mixture of text and numbers. For example. Apple12, UK55.

    Thanks

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Non Array Formula to pull unique values and sort in a range

    The usual way of sorting by formulae is to use the RANK function or the SMALL (or LARGE) function. These all operate on numeric values, so I'm not sure how you would do this with text values.

    Pete

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Non Array Formula to pull unique values and sort in a range

    I am not sure if there is a non-array formula that would extract unique values and sort. However, an array formula can do that
    Give this one a try
    Assuming your data range is A2:A4000
    Your first array formula to count unique values in B$1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    then next array formula that will get the unique records and sort: Enter in B2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Last edited by AlKey; 10-23-2016 at 05:33 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2502
    Posts
    13,700

    Re: Non Array Formula to pull unique values and sort in a range

    I did this with all text, and blended the above suggestions in 3 helper columns.

    Random U.S. states are in column A with duplicates.

    Unique data in column B with
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Alpha ranked in column C with
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Rank those ranks in column D with
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And the final sorted formula in column E
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It's more steps than an array.
    Dave

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Non Array Formula to pull unique values and sort in a range

    Dave,

    that's great. You can avoid the errors (purely for aesthetic purposes) by using this in C1:

    =IF(B1<>"",COUNTIF($B$1:$B$25,"<="&$B$1:$B$25),"")

    and this in D1:

    =IF(C1="","",RANK(C1,$C$1:$C$25,1))

    Hope this helps.

    Pete

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2502
    Posts
    13,700

    Re: Non Array Formula to pull unique values and sort in a range

    Yes, Pete. Good idea! Thanks for that. I was so surprised that it worked I missed it. LOL

  11. #11
    Registered User
    Join Date
    11-28-2003
    Posts
    1

    Re: Non Array Formula to pull unique values and sort in a range

    Thank You So much

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Non Array Formula to pull unique values and sort in a range

    WOW!! Is that really your first post after joining in November 2003 ?

    Pete

  13. #13
    Forum Contributor
    Join Date
    05-21-2019
    Location
    Tabriz,Iran
    MS-Off Ver
    2024
    Posts
    195

    Re: Non Array Formula to pull unique values and sort in a range

    Hi all,

    I need this formula without VBA & Helper columns & Array formula (Ctrl + shift + Enter)

    =IF(ROWS(B$2:B2)>B$1,"",INDEX($A$2:$A$5000,MATCH(0,COUNTIF($A$2:$A$5000,"<"&$A$2:$A$5000)-SUM(COUNTIF($A$2:$A$5000,$B$1:B1)),0)))

    Thank you so much for the help me
    Notice:
    my main language is not English

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Non Array Formula to pull unique values and sort in a range

    Yaghoub61. By now you should know the forum rules. Thread hijacking is NOT allowed.

    Rule 4: Do not post a new help request in an existing thread.

    Start your OWN thread and post a small sample sheet.

    Thread closed.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find Unique Values - Need Not Array Formula
    By Neyme in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-30-2016, 04:36 PM
  2. Array Formula To Return Unique Values From a Column Using a Value
    By lucas813 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 02-13-2015, 12:07 PM
  3. [SOLVED] Array formula to extract and sort unique values from two worksheets
    By rshukla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2013, 06:11 AM
  4. Pull Unique Values from a List and Automatically Sort in Alphabetical Order
    By Aimee S. in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2013, 09:43 AM
  5. add to array formula to only return unique values
    By jason892 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-11-2013, 06:39 AM
  6. Sort Unique Values in Combobox By Number Of Times Used In Range
    By trenars in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2012, 10:19 AM
  7. Replies: 3
    Last Post: 11-24-2011, 06:11 AM

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