How to sort numbers?

excelos

Active Member
Joined
Sep 25, 2011
Messages
329
Hello

I have a row with numbers 1,5,5,5,4,4,3,3,0,1

How can I sort them so that they are ranked by ascending number and the most left is the first if more than two same values exist?
Also, how do I return the value that is second maximum and if more than one values, return the cell address of the second one, ie second from left?

Thanks!
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

oldbrewer

Board Regular
Joined
Apr 11, 2010
Messages
11,003
in a helper column put the number plus row number multiplied by .00000001
then sort using small function

or column number if your list is horizontal
 

AlKey

Active Member
Joined
Oct 15, 2013
Messages
395
Assuming the numbers are in cell A1

If you use Excel version 2010 or higher you can use AGGREGATE function
Enter formula in cell B1 and drag formula down
Code:
[B]=AGGREGATE(15,6,--MID(SUBSTITUTE(A$1,",",REPT(" ",99)),99*(COLUMN(A:Z)-1)+1,99),ROWS(A$1:A1))[/B]
Otherwise use array formula. **Must be entered with Ctrl+Shift+Enter key combination.
Code:
[B]=SMALL(IFERROR(--MID(SUBSTITUTE(A$1,",",REPT(" ",99)),99*(COLUMN(A:Z)-1)+1,99),""),ROWS(A$1:A1))[/B]
 
Last edited:

oldbrewer

Board Regular
Joined
Apr 11, 2010
Messages
11,003
1,5,5,5,4,4,3,3,0,1
1555443301
0113344555row 4
12345678910
1.0000000355544331.1E-071row 18
formula giving the zero in row 4
=IF(SMALL($C$18:$L$18,C17)<1,0,SMALL($C$18:$L$18,C17))
formula giving the first number in row 18
=C3+COLUMN()*0.00000001

<colgroup><col span="2"><col><col span="13"></colgroup><tbody>
</tbody>
 

AlKey

Active Member
Joined
Oct 15, 2013
Messages
395
You did not mention that sorting should be in columns
Enter formula in B1 and drag across until you see blanks
For Excel 2010 and higher:
Code:
[B]=IFERROR(AGGREGATE(15,6,--MID(SUBSTITUTE($A1,",",REPT(" ",99)),99*(COLUMN(1:1)-1)+1,99),COLUMNS($B:B)),"")[/B]

For the Excel version 2007 and up use array formula
Code:
[B]=IFERROR(SMALL(IFERROR(--MID(SUBSTITUTE($A1,",",REPT(" ",99)),99*(COLUMN(1:1)-1)+1,99),""),COLUMNS($B:B)),"")[/B]
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,109,325
Messages
5,528,023
Members
409,799
Latest member
mlewan_ca

This Week's Hot Topics

Top