Exceljet

Quick, clean, and to the point

Sort numbers ascending or descending

Excel formula: Sort numbers ascending or descending
Generic formula 
=SMALL(data,ROWS(exp_rng))
Explanation 

To dynamically sort a list of numbers in ascending order, you can a simple formula based on the SMALL function with an expanding range. In the example shown, the formula in cell C5 is:

=SMALL(data,ROWS($B$5:B5))

where "data" is the named range B5:B14

How this formula works

The SMALL function is meant to extract the "nth" smallest value from a set of data. The value for N is supplied as the second argument. To get the smallest value with SMALL, supply 1, to get the second smallest value, supply 2, and so on.

=SMALL(data,1) // 1st smallest
=SMALL(data,2) // 2nd smallest
=SMALL(data,3) // 3rd smallest

In the example shown, "data" is the named range B5:B14. In this example, the main challenge is to increment a value for nth. This is done by using an expanding range inside the ROWS function:

ROWS($B$5:B5)

As the formula is copied down the table, the range expands and the number or rows increases, with supplies an incrementing value.

Sort numbers in descending order

To sort numbers in descending order, simply replace the SMALL function with the LARGE function:

=LARGE(data,ROWS(exp_rng))

Like SMALL, the LARGE function extracts an "nth" value. However, rather than the "nth smallest" LARGE returns the the "nth largest".

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.