Article updated on November 15, 2013

Count cells between two values in a column

Formula in D15:

=ABS(MATCH(C12, A1:A10, 0)-MATCH(C13, A1:A10, 0))-1

Count cells between two values in a row

Formula in D23:

=ABS(MATCH(C20, A18:E18, 0)-MATCH(C21, A18:E18, 0))-1

Download excel sample file for this tutorial.

formula to count cells between two values.xls
(Excel 97-2003 Workbook *.xls)

Functions in this article:

MATCH(lookup_value;lookup_array; [match_type])
Returns the relative position of an item in an array that matches a specified value

Returns the absolute value of a number, a number without its sign.