Excel Sort by Rank: Formulas & Steps

Formulas & functions · Updated November 23, 2026

The quickest way to sort by rank in Excel is to first assign ranks with the RANK.EQ function (or RANK in older versions), then sort the data by that rank column using the Sort feature on the Data tab. For example, with scores in B2:B10, enter =RANK.EQ(B2,$B$2:$B$10) in C2 and copy down, then sort by column C.

Why Ranking and Sorting Are Different

Ranking assigns a position number (1st, 2nd, 3rd) to each value, while sorting physically reorders rows. You might want to rank without reordering (to keep original order) or sort without ranking (just alphabetical or numeric). But often you need both: rank first, then sort by that rank to see the list in order of performance. Excel has no single “sort by rank” button; you combine the two operations.

Using RANK.EQ to Create a Rank Column

The RANK.EQ function returns the rank of a number within a list. Its syntax is:

=RANK.EQ(number, ref, [order])

  • number – the cell containing the value to rank.
  • ref – the range of all values (use absolute references like $B$2:$B$10).
  • order – optional; 0 or omitted for descending (largest gets rank 1), 1 for ascending (smallest gets rank 1).

Example: With scores in B2:B10, put this in C2 and copy down:

=RANK.EQ(B2,$B$2:$B$10,0)

If B2:B10 contains 80, 95, 70, 95, 60, 85, 75, 90, 65, the ranks will be 6, 1, 8, 1, 9, 3, 7, 2, 5. Note that tied values (two 95s) both get rank 1, and the next rank skips to 3. That’s standard competition ranking.

Sorting by the Rank Column

After you have the rank column, select the entire data range (including headers), then:

  1. Go to the Data tab.
  2. Click Sort (the A→Z or Z→A icon opens the dialog).
  3. In the dialog, choose the column with your ranks (e.g., “Rank”).
  4. Set Sort On to “Values” and Order to “Smallest to Largest” (since rank 1 is best).
  5. Click OK.

On a Mac, the steps are identical. In Excel for the web, the Sort dialog works the same way. If you prefer, you can use the Sort by dropdown on the Home tab (Editing group) in newer versions.

Handling Ties and Duplicate Ranks

When two values tie, RANK.EQ gives them the same rank and skips the next rank. If you need unique ranks (no ties), use RANK.EQ plus a tiebreaker. One common method:

=RANK.EQ(B2,$B$2:$B$10)+COUNTIF($B$2:B2,B2)-1

This adds 1 for each previous occurrence of the same value, so the first 95 gets rank 1, the second 95 gets rank 2, and the next distinct value gets rank 3 (no gaps). Another approach uses COUNTIFS with a second criterion, but the above is simple and works in all versions.

Dynamic Sorting with SORT and SORTBY

If you have Excel 2021 or Microsoft 365, you can sort without changing the original data using the SORT or SORTBY functions. These return a new array that spills into adjacent cells.

To sort by rank dynamically, first compute ranks in a helper column (say C), then use:

=SORT(A2:C10, 3, 1)

This sorts the range A2:C10 by column 3 (the rank) in ascending order (1 = smallest to largest). If you want to sort by the original values descending without a rank column, you can use:

=SORT(A2:B10, 2, -1)

where -1 means descending. SORTBY is similar but lets you sort by a separate range, e.g., =SORTBY(A2:B10, B2:B10, -1).

These functions are not available in Excel 2019 or earlier; there you must use the Sort dialog.

Common Mistakes and How to Avoid Them

  • Not using absolute references in the rank formula – if you copy down without $, the range shifts and ranks become wrong. Always use $B$2:$B$10 style.
  • Sorting only the rank column – if you select only column C and sort, the rows get shuffled but the other columns stay put, destroying your data. Always select the full range.
  • Sorting by rank but forgetting ties – ties cause equal ranks; decide whether you want gaps or unique ranks before sorting.
  • Using RANK instead of RANK.EQ – RANK still works for compatibility, but RANK.EQ is the current function; RANK.AVG gives average ranks for ties (e.g., two 95s would both get 1.5).

Alternatives: Pivot Tables and Conditional Formatting

If you need to rank and sort frequently, a Pivot Table can do both without formulas. Drag the value field into the Values area, then right-click and choose Sort > Largest to Smallest. You can also show ranks by adding the field again and setting Show Values As > Rank.

Conditional Formatting can highlight top or bottom ranks visually without sorting. Select the data, go to Home > Conditional Formatting > Top/Bottom Rules, and choose Top 10 Items or use a formula like =RANK.EQ(B2,$B$2:$B$10)<=5 to highlight the top 5.

Frequently Asked Questions

How do I rank in Excel without sorting?
Use the RANK.EQ function in a helper column. It returns the rank for each value without changing the row order. For example, =RANK.EQ(B2,$B$2:$B$10) gives ranks that you can then sort by if needed.

What is the difference between RANK.EQ and RANK.AVG?
RANK.EQ gives tied values the same rank (e.g., two 95s both get 1, next is 3). RANK.AVG gives tied values the average of the ranks they would occupy (e.g., two 95s both get 1.5). Choose based on whether you want competition ranking or average ranking.

Can I sort by rank automatically when new data is added?
Yes, if you use the SORT or SORTBY functions (Excel 2021 or 365), the sorted list updates automatically when source data changes. With the classic Sort dialog, you must re-sort each time.

Why does my rank formula show #N/A?
This usually happens if the ref range contains errors, or if the number being ranked is not found in the range (e.g., a text value). Ensure all values in the range are numeric and that the range is correct.

How do I rank with multiple criteria (e.g., same score, higher bonus wins)?
Create a combined score using a formula like =B2*1000+C2 (where B is score and C is bonus), then rank that new column. Or use COUNTIFS to count how many values are greater, plus a tiebreaker. For example: =COUNTIFS($B$2:$B$10,">"&B2)+COUNTIFS($B$2:$B$10,B2,$C$2:$C$10,">"&C2)+1.

Is there a keyboard shortcut to sort?
In Excel on Windows, select the data and press Alt + A + S + A to open the Sort dialog (or Alt + D + S in older versions). On Mac, use Cmd + Shift + R to open Sort.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.