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.
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.
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
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.
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
Thank you all so much for your help. You put me on the right track.
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,
**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).![]()
Please Login or Register to view this content.
Drag down as far as neeeded.
Quang PT
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)),),)),"")
@bebo: As per the first post unique values were already extracted.
Regards
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.
I want thank you guys for the help you have provided. I'm applying this solution.
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.![]()
Please Login or Register to view this content.
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. :/
="A">"a"
char() is opposite of code()
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.
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.
edit, crosspost
Last edited by RaulSerg; 07-07-2020 at 04:11 PM.
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
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?
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)),"")
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)
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.
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.
Okay, you are a genius. I'm not sure what I was missing but you solved it RaulSerg!! Thank you so much.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks