Excel Supreme

Excel track · Exercise 14 of 86 Paid

Rank a list without sorting it

Put a place number on every row of an unsorted list, in either direction.

Intermediate

A team of swim times ranked both ways

Read-only data · screen 1 of 2 · answer in C2

Put Ada's place in the team into C2 using the default order, without sorting the sheet.

ABC
1SwimmerSecondsPlace
2Ada58
3Ben61
4Cleo55
5Dev57
6Eli50

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

C2

What it does

RANK compares one value against a range and returns the place it takes. The optional third argument sets the direction: 0 or nothing ranks the largest number first, and any other value ranks the smallest first. The range needs anchoring with dollar signs so it does not slide when the formula is filled down.

On this sheet the times run 58 in B2, 61 in B3, 55 in B4, 57 in B5 and 50 in B6. Ranked from the largest down, 61 takes place 1 and Ada's 58 takes place 2. A third argument of 1 turns the order round, and her 58 becomes place 4 with Eli's 50 at the top.

Equal values share a place and the next one is skipped, so two swimmers on 61 are both first and nobody is second. A total built by adding ranks will then miss a number, because a rank names a row and does not count rows.

Syntax

=RANK(number, ref, [order])

Worked example

On A team of swim times ranked both ways, =RANK(B2,B2:B6) returns 2.

=RANK(B2,B2:B6)

Common errors

Error codes for RANK, and anchoring the range it compares against
ErrorWhat it means and how to fix it
#N/AThe value being ranked is not in the range, which happens when the number argument points at a different row from the list.
#VALUE!The number argument is text, so there is nothing to compare with the other values.
Order backwardsA third argument of 1 ranks the smallest value first, so a missing argument flips every place on the sheet.

At work

A league table showing each swimmer's place on the row they already sit in, and the same sheet ranked the other way for handicaps.