How to sort table using function/equation only

Season picture Season · Feb 21, 2013 · Viewed 55.6k times · Source

How can I sort a table in sheet 1 like

A B C D E
3 7 3 6 5

into another table in sheet 2

A C E D B
3 3 5 6 7

by using function only?

Answer

Stepan1010 picture Stepan1010 · Feb 21, 2013

One really easy way to do it would be to just have a rank index and then use HLOOKUP to find the corresponding values:

=RANK(A4,$A$4:$E$4,1)

Example 1

=IF(COUNTIF($A$1:A$1,A1)>1,RANK(A4,$A$4:$E$4,1)+COUNTIF($A$1:A$1,A1)-1,RANK(A4,$A$4:$E$4,1))

Example 2

=HLOOKUP(COLUMN(),$A$2:$E$4,2,FALSE)

Example 3

=HLOOKUP(COLUMN(),$A$2:$E$4,3,FALSE)

Example 4