Author: Oscar Cronquist Article last updated on July 30, 2017

Question: How do I rank text cell values uniquely? If text values were sorted alpabetically from A to Z, the first text value would rank 1 and so on... Duplicate text values rank uniquely.



Array formula in B2:

=COUNTIF(List, "<"&A2)+SUM(IF(A2=$A$2:A2, 1, 0))  + Enter

Copy cell B2 and paste  down as far as needed.

Named ranges

What is named ranges?

How does this formula work?

Let us start with cell B2.

=COUNTIF(List, "<"&A2)+SUM(IF(A2=$A$2:A2, 1, 0))

Step 1 - Calculate rank

=COUNTIF(List, "<"&A2)


=COUNTIF({DD, AA, AA, BB, AA, DD, EE, AA, BB, EE, CC, EE}, "<"&DD)

and returns 7. 7 values are sorted before DD, as if they were sorted from A to Z.

Step 2 - Count current value and prior instances of current value

Keep in mind, countif doesn´t rank uniquely if duplicate values are found.

SUM(IF(A2=$A$2:A2, 1, 0))


SUM(IF("DD"="DD", 1, 0))


SUM(1) and returns 1

Step 3 - Add values

Step 1 returned 7 and step 2 returned 1. 7 + 1 equals 8.

Final comments

Select B3 and use "evaluate formula" to see how the next cell calculates rank. Click "Evaluate" button and excel calculates cell formula step by step.

Download excel example file.

(Excel 97-2003 Workbook *.xls)

Functions in this article:

Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE

Adds all the numbers in a range of cells

Counts the number of cells within a range that meet the given condition