Alphabetical ranking

Today I faced the challenge of having to find the rank of a text string in a range of text strings. Or put another way, in what position would the entry sit alphabetically?

The RANK function only works on numeric values. So instead, we have to resort to logic.


This will figure out how many cells within the range A1:A5 are less than or equal to A1, the value that we're trying to rank.

A beautiful yet simple piece of logic, learned from "anhn" inĀ VB Forums.

This entry was posted in Quick tips and tagged , . Bookmark the permalink.

3 Responses to Alphabetical ranking

  1. Mohan says:

    This does not work if Text are in Duplicated

  2. Juoquim says:

    For small lists with, just add a space to the end of one of the duplicated pieces of text. This works great. It would not however be practical for large lists with many duplicates.

  3. James says:

    A slight variation of the above formula will give you a true ranking, even if there are duplicate entries:

    =COUNTIF(A1:A5,"<"&A1)+1 However, if you sorting, the following works better: =COUNTIF(A$1:A$5,"<"&A3)+1+IF(COUNTIF(A$1:A1,A1)>1,COUNTIF(A$1:A1,A1)-1,0)

    Not as elegant, but it works by counting the number of duplicate entries above the current row and adding that number back to the rank, so it becomes not a true ranking but a sorting.

Comments are closed.