+ Reply to Thread
Results 1 to 23 of 23

Alphabetize a unique list based on criteria

  1. #1
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Alphabetize a unique list based on criteria

    Hey everyone, I'm successfully using this index to get unique values from a list. But how can I alphabetize this list?

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    Attached one possible way with a helper column.

    =COUNTIF(B$2:B$21,"<"&B2)+1 to just rank the data and then a simple index/match to sort.

    Regards
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Alphabetize a unique list based on criteria

    Hi Raul,
    can you please explain how does the countif work here?

    thanks

  4. #4
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    Quote Originally Posted by belinda200 View Post
    Hi Raul,
    can you please explain how does the countif work here?

    thanks
    Excel does have a sorting order, basically underlying also the 'sort' function (both now new in office 365 and the previous one available via the menu).
    Simplified, numbers are smaller than letters, capital letters are smaller than non-capital letters, and special characters are all over the place.
    Just play around with =A>a etc.
    I believe it is chiefly (if not completely) based on the/some unicode character set.

    e.g. just apply =unichar(...) from 1 to 10,000 and beyond and compare that the further down you go, the "larger" Excel considers the signs/numbers/letters etc. in terms of "comparing" them.

    The same procedure can be applied to entire words, e.g. Aaron is clearly "smaller" than Arya as it appears earlier in the same way as you would probably rank it.
    Likewise, Aaro1n is smaller than Aaron as 1 (unicode 49) is smaller than n (unicode 110).

    And the countif function employs the same, checking how many strings in the range are smaller/larger than the criteria (subject textstring) used.

    Hope this helps.

    Regards
    Last edited by RaulSerg; 07-05-2020 at 04:19 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    btw - unichar() might not be available in Excel 2010 (only since Excel 2013 I think) if you're still using that; but the char() function provides for the same data for all normal purposes (values 1 to 255).

    Regards

  6. #6
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Thank you all so much for your help. You put me on the right track.

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,646

    Re: Alphabetize a unique list based on criteria

    Solution that you get so far, may does not work with duplicate name in B column.
    Do you expect to get the unique name list in alphabet order?

    try in G2,

    Please Login or Register  to view this content.
    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

    Drag down as far as neeeded.
    Attached Files Attached Files
    Quang PT

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Alphabetize a unique list based on criteria

    Another sort unique list

    F2
    =IFERROR(INDEX($B$2:$B$90,MATCH(0,INDEX(COUNTIFS($B$2:$B$90,"<"&$B$2:$B$90)-SUMPRODUCT(COUNTIFS($B$2:$B$90,F$1:F1)),),)),"")
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    @bebo: As per the first post unique values were already extracted.

    Regards

  10. #10
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Just a note about the $B$1 cell, this is a drop down that when I select a different value I get a unique list based on what I have selected from the drop list


    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    I want thank you guys for the help you have provided. I'm applying this solution.

    Please Login or Register  to view this content.
    My next goal is to get the below formula to ignore blank cells. But this works as long as the cells have data in them.

  12. #12
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Alphabetize a unique list based on criteria

    RaulSerg ,

    Thank you for the deatailed explanation. this is really interesting!
    BTW - when I try to apply this formula =A>a I get #NAME?
    Can you please explain why?

    I indeed dont have the unichar function available, and also the CHAR function, although available, returns a symbol instead of a number. :/

  13. #13
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    ="A">"a"

    char() is opposite of code()

  14. #14
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    You know, that long formula I posted earlier looked a bit awkward. So here is a shorted version using a self expanding named range. Here is the challenge that I'm having. I can't see to be able to add a criteria to the formula that will let me select the list I want to see based on a dropdown.

    Any thoughts anyone?

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    The criteria that I want to use in the formula would access column B. Say for example, If I select FOOD, then only those items categorized as FOOD will populate the list. I've attached the workbook for everyone to look at.
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    edit, crosspost
    Last edited by RaulSerg; 07-07-2020 at 04:11 PM.

  17. #17
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    Try to just add the condition? That is: instead of: COUNTIF($A$2:A2,MyCRange)=0
    Do: (COUNTIF($A$2:A2,MyCRange)=0)*(OFFSET(MyCRange,,-1)=$B$1)
    This works for me.

    btw - you should remove the spaces from your formulas; in Excel spaces are the intersection operation which may or may not cause unexpected problems with your formulas

    Regards

  18. #18
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Thank you for your thoughts. But I'm getting an error that won't allow me to apply the change. The error occurs at the =0 portion of the formula. What am I doing wrong?

  19. #19
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    Sounds like you got the brackets wrong.

    =IFERROR(INDEX(MyCRange,MATCH(SMALL(IF((COUNTIF($A$2:A2,MyCRange)=0)*(OFFSET(MyCRange,,-1)=$B$1),COUNTIF(MyCRange,"<"&MyCRange),""),1),COUNTIF(MyCRange,"<"&MyCRange),0)),"")

  20. #20
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Maybe this will help. I've added another named range called MyBRange. I've also added an image that shows the columns used by the array. Column B contains the category criteria (MyBRange)

  21. #21
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Okay, I'm able to apply the formula below but I'm not getting any results, just a blank space. The MyBrange is the category column. The MyCRange is the Items columns. B$7 should look in column B (Categories) and based on the category selected it will only display those items (MyCRange) that have the category.

    Please Login or Register  to view this content.

  22. #22
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    693

    Re: Alphabetize a unique list based on criteria

    I am not sure what more I can add. The formula I provided is copy paste and works fine for me.
    Adding more named ranges or whatever is unnecessary.

    Here's your workbook. Let me know if that works for you or what exactly is not giving you the result you expect.
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    01-21-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Alphabetize a unique list based on criteria

    Okay, you are a genius. I'm not sure what I was missing but you solved it RaulSerg!! Thank you so much.

+ 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] Extract unique sub-list from repeated list based on criteria
    By Mohamed Elgammal in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-30-2019, 11:27 AM
  2. [SOLVED] Unique Sorted List(s) based on certain criteria
    By Nobleks in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-27-2019, 04:23 PM
  3. Formula to alphabetize based on criteria
    By Stuepef in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2019, 05:24 AM
  4. List Unique Values Based On Criteria
    By tangmere.milli in forum Excel General
    Replies: 5
    Last Post: 03-16-2015, 09:49 AM
  5. [SOLVED] Create list based on criteria and is unique
    By joannelittell in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-13-2013, 02:33 PM
  6. Unique dropdown list based on two criteria but...
    By Darsk in forum Excel General
    Replies: 2
    Last Post: 09-28-2011, 04:37 PM
  7. Excel Formula to Alphabetize Unique items only from a list
    By broshannon in forum Excel General
    Replies: 3
    Last Post: 09-06-2010, 08:07 AM

Tags for this Thread

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