# Count number a times a specific value appears consecutively.

1. ## Count number a times a specific value appears consecutively.

Would like a function formula that counts the number a times a specific value appears consecutively in a specific column.

Ex. In column H62:H96, the values appear (vertically):
1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0

I would like a formula i could drag across multiple columns that calculates the number of times the value '1' appears consecutively. However, i dont want it to count every time it appears consecutively, only the time it appears the most. For example, the above sequence would yield a value of 7 because the number 1 appeared 7 times in a row at its max.

Thank you!  Register To Reply

2. ## Re: Count number a times a specific value appears consecutively.

Try this array formula**:

=MAX(FREQUENCY(IF(H62:H96=1,ROW(H62:H96)),IF(H62:H96<>1,ROW(H62:H96))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.  Register To Reply