How to sort numbers?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
591
Office Version
  1. 365
Platform
  1. Windows
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!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
 
Upvote 0
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:
Upvote 0
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>
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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