Highlight the max number of consecutive positive numbers

Viewed 156

Trying to Highlight the max number of consecutive positive numbers.

enter image description here

with the help of the following formula, can able to get the max number of consecutive positive numbers. but when tried to be applied as a conditional formula - no luck.

{=MAX(FREQUENCY(IF(A2:A20>0,ROW(A2:A20)),IF(A2:A20<=0,ROW(A2:A20))))}

1 Answers

So if you do have Xmatch, you can search both forwards and backwards for the previous and next rows which have a value less than or equal to 0 and compare the difference in the two row numbers to the maximum value of the frequency:

=AND((IFERROR(XMATCH(TRUE,A2:A$20<=0,0,1),22-ROW())+ROW()-IFERROR(XMATCH(TRUE,A$1:A1<=0,0,-1),1)-2)
=MAX(FREQUENCY(IF(A$2:A$20>0,ROW(A$2:A$20)),IF(A$2:A$20<=0,ROW(A$2:A$20)))),A2>0)

for the particular case where you are looking at rows 2-20.

enter image description here

Related