How do I create a unique sorted list?

sroberts

New Member
Joined
Nov 25, 2008
Messages
4
I successfully used the following functions to create a unique list of "units" (store numbers in a multi-store list) thanks to help from this site. However the list that is created is not in alphanumeric sort and I need the units to be sorted alphanumerically - hopefully without having to click on some sort macro... is there a way to modify this formula to return a sorted list?

=IF(ROWS($A$3:A3)<=$A$1,INDEX(Unit,
SMALL(IF(FREQUENCY(IF(Unit<>"",
MATCH("~"&Unit&"",Unit&"",0)),
ROW(Unit)-ROW(Sheet1!$AC$6)+1),ROW(Unit)-ROW(Sheet1!$AC$6)+1),
ROWS($B$3:B3))),"")
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
It would be easier, and more efficient, to use Excel's sort feature. However, if you'd like a formula solution, and the data contains numerical values, try...

=IF(ROWS($A$3:A3)<=$A$1,SMALL(IF(FREQUENCY(IF(Unit<>"",MATCH("~"&Unit,Unit&"",0)),ROW(Unit)-MIN(ROW(Unit))+1),Unit),ROWS(A$3:A3)),"")

If the data contains text values (or a mix of text and numerical values), try...

=IF(ROWS($A$3:A3)<=$A$1,INDEX(Unit,MATCH(SMALL(IF(FREQUENCY(IF(Unit<>"",MATCH("~"&Unit,Unit&"",0)),ROW(Unit)-MIN(ROW(Unit))+1),MMULT(--(Unit>TRANSPOSE(Unit)),ROW(Unit)^0)),ROWS(A$3:A3)),MMULT(--(Unit>TRANSPOSE(Unit)),ROW(Unit)^0),0)),"")

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Last edited:
Upvote 0
Alternatively, build a one-column pivot table. You can then copy and paste as values, to be left with just the list

Denis
 
Upvote 0
It would be easier, and more efficient, to use Excel's sort feature.
Make that...

1) 'Use Advanced Filter > Unique records only' for a list of unique values.

2) Use 'Sort' to list values in alpha/numeric order.
 
Upvote 0
I am familiar with VBA but don't know VB per se. AFAIK, "SELECT DISTINCT" will only have any meaning in SQL.
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top