How to Use the RANK Formula in Excel
In this article
To rank a number in Excel, use the RANK function (or its newer replacement RANK.EQ) with the syntax =RANK(number, ref, [order]), where number is the value you want to rank, ref is the range or array of numbers to rank against, and order is 0 or omitted for descending (largest = 1) or 1 for ascending (smallest = 1). This gives you the position of each value within a dataset, useful for leaderboards, sales comparisons, or test scores. You need a spreadsheet with numeric data and a cell for the formula.
What You'll Need
- Microsoft Excel (any modern version; RANK works in Excel 2007 and later, and RANK.EQ is available from Excel 2010 onward).
- A dataset with at least one column of numbers to rank.
- A blank cell where you will enter the formula.
Step-by-Step
- Identify your data range. Suppose your numbers are in cells B2 through B10. Note the range; you will use it as the ref argument.
- Select the cell where you want the rank to appear. For example, click cell C2 next to the first number.
- Type the formula. Enter
=RANK(B2, $B$2:$B$10, 0)and press Enter. This ranks the value in B2 against all values in B2:B10 in descending order (largest value gets rank 1). - Use absolute references for the range. The dollar signs ($B$2:$B$10) lock the range so you can copy the formula down without it shifting. If you omit them, the range will move relative to each row and give wrong results.
- Copy the formula down. Drag the fill handle from C2 down to C10 to rank each number. Each row will rank its own value against the full range.
- Choose ascending order if needed. If you want the smallest number to get rank 1, change the last argument to 1:
=RANK(B2, $B$2:$B$10, 1). - Consider RANK.EQ for newer Excel versions. RANK.EQ works identically but is the recommended function from Excel 2010 onward. Use
=RANK.EQ(B2, $B$2:$B$10, 0)for the same result. - Handle ties. Both RANK and RANK.EQ assign the same rank to duplicate values, and the next rank is skipped (e.g., two values tied for 1st, next is 3rd). If you need unique ranks for ties, use RANK.EQ plus COUNTIF as a tiebreaker:
=RANK.EQ(B2, $B$2:$B$10, 0) + COUNTIF($B$2:B2, B2) - 1.
Common Mistakes
- Forgetting absolute references. Using a relative range like B2:B10 instead of $B$2:$B$10 causes the range to shift as you copy the formula, producing incorrect ranks.
- Including non-numeric cells in the range. RANK ignores text, logical values, and empty cells, but if your range includes them, the count of numbers may be off, leading to unexpected ranks. Ensure the range contains only numbers.
- Mixing up the order argument. Omitting the order argument or using 0 ranks largest as 1; using 1 ranks smallest as 1. Double-check which you need.
- Using RANK in Excel 2010+ without knowing it's deprecated. RANK still works but Microsoft recommends RANK.EQ for new formulas. Both behave the same for ties.
- Expecting unique ranks for ties. RANK and RANK.EQ give duplicate values the same rank. If you need distinct ranks, add a tiebreaker as shown in step 8.
Tips
- Use named ranges (e.g., define B2:B10 as "Scores") to make formulas easier to read:
=RANK(B2, Scores, 0). - If you want to rank within a filtered list, consider using SUBTOTAL or AGGREGATE with RANK, but note RANK itself does not ignore hidden rows.
- To rank in ascending order (smallest = 1), set the third argument to 1. This is useful for ranking times or costs where lower is better.
- For dynamic arrays in Excel 365, you can use RANK.EQ with a spilled range, but ensure the ref is still an absolute range or a structured reference.
- Combine RANK with IF to conditionally rank, e.g., rank only values above a threshold:
=IF(B2>100, RANK(B2, $B$2:$B$10, 0), "").
Troubleshooting
- Formula returns #N/A: The number argument is not found in the ref range. Check that the value exists and that the range is correct.
- Formula returns #VALUE!: The number argument is non-numeric or the ref contains text that cannot be interpreted. Ensure all referenced cells contain numbers.
- Ranks look wrong after copying: Likely a relative reference issue. Make sure the ref range uses absolute references (with $ signs).
- Ties give unexpected results: RANK assigns the same rank to duplicates and skips subsequent ranks. If you need unique ranks, use the COUNTIF tiebreaker method described in step 8.
- RANK not available: In very old Excel versions (pre-2007), RANK exists but may have limited functionality. In Excel Online, RANK and RANK.EQ are supported. If you see #NAME?, check that you spelled the function correctly.
Frequently Asked Questions
What is the difference between RANK and RANK.EQ?
RANK is the original function, still available for compatibility. RANK.EQ is the newer version introduced in Excel 2010 and is recommended for new formulas. They behave identically for ranking, including handling ties the same way.
Can I rank only visible cells in a filtered list?
RANK does not ignore hidden rows. To rank only visible cells, use AGGREGATE with option 5 (ignore hidden rows) or SUBTOTAL, but these do not directly provide rank. A workaround is to use a helper column with SUBTOTAL to flag visible rows, then use RANK on that helper column.
How do I rank in ascending order?
Set the third argument of RANK or RANK.EQ to 1. For example, =RANK(B2, $B$2:$B$10, 1) gives the smallest value a rank of 1.
Why does RANK give the same rank to duplicate values?
By design, RANK and RANK.EQ assign the same rank to identical values and then skip the next rank. For example, if two values tie for 2nd, the next value gets rank 4. To assign unique ranks, add a COUNTIF tiebreaker as shown in the steps.
Can I use RANK with a named range?
Yes. Define a name for your range (Formulas > Define Name) and use it in the formula, e.g., =RANK(B2, Scores, 0). This makes formulas easier to read and maintain.
Does RANK work in Excel for Mac?
Yes, RANK and RANK.EQ are available in Excel for Mac (version 2011 and later). The syntax and behavior are the same as in Windows Excel.