Assuming you have cat in cell c1
, the following formula will return the first continuous matching range. Enter with ctrl+shift+enter
=COUNTIF(OFFSET(A1:A5,MATCH(C1,A1:A5,0)-1,0,MATCH(TRUE,OFFSET(A1:A5,MATCH(C1,A1:A5,0),0)<>C1,0)),"cat")
If your data always start in A1 and you want the whole range matching the first value, all the way until the next value, use the following array formula (entered with ctrl+shift+enter):
=OFFSET($A$1,0,0,MATCH(TRUE,A:A<>A1,0)-1)