Excel: Ranking Number Range with Array FormulaLast reviewed: November 30, 1994Article ID: Q65398 |
The information in this article applies to:
SUMMARYIn Microsoft Excel, version 4.0, use the RANK function to rank a range of numbers according to their numerical value. To rank the numbers from small to large, where the small number is the first in rank, use the following function:
=RANK(firstcell,range,-1)To rank them from large to small, use the following function:
=RANK(firstcell,range)In Microsoft Excel versions prior to 4.0, to rank a range of numbers according to their numerical value from small to large or large to small, use one of the following array formulas, where "range" is the range of numbers to be ranked and "firstcell" is the first cell in "range":
=ROWS(range)-SUM(IF(range>=firstcell,1,0))+1 (to rank from small to large) =ROWS(range)-SUM(IF(range>firstcell,0,1))+1 (to rank from large to small)To enter the formula, do the following:
MORE INFORMATIONThe following formulas will return the correct ranking of the numbers in cells $A$1:$A$5 (the braces {} indicate that the formula was entered as an array by pressing COMMAND+ENTER in Microsoft Excel for the Macintosh or CONTROL+SHIFT+ENTER in Microsoft Excel for Windows:
A1: 50 B1: {=ROWS($A$1:$A$5)-SUM(IF($A$1:$A$5>=A1,1,0))+1} A2: 12 B2: {=ROWS($A$1:$A$5)-SUM(IF($A$1:$A$5>=A2,1,0))+1} A3: 42 B3: {=ROWS($A$1:$A$5)-SUM(IF($A$1:$A$5>=A3,1,0))+1} A4: 31 B4: {=ROWS($A$1:$A$5)-SUM(IF($A$1:$A$5>=A4,1,0))+1} A5: 1 B5: {=ROWS($A$1:$A$5)-SUM(IF($A$1:$A$5>=A5,1,0))+1}The values that are returned from the above formulas are as follows:
A1: 50 B1: 5 A2: 12 B2: 2 A3: 42 B3: 4 A4: 31 B4: 3 A5: 1 B5: 1 |
KBCategory: kbusage
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |