View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default Counting consecutive negative value

"Wallace" wrote:
I have a column with positive and negative numbers.
I need to count the largest number of consecutive
negative numbers and don't really know how to do it.


First, do you really want to count "consecutive negative numbers" per se, or
do you really want to count "number of consecutive cells with negative
numbers"?

In the first case, consecutive cells with values -1, -2 and -4 would count
as 2; in the second case, they would count as 3.

You should be able to adapt the following approach in either case. But if
you need assistance with that, you need to be more precise.

This might not be the best approach, but it's simple. I believe someone (T
"Biff" Valko?) was able to implement this approach in a single array formula.

Suppose your numbers are in A1:A30. In B1, put the formula =--(A1<0). And
put the following formula into B2 and copy down: =(A2<0)*(B1+1).

Then =MAX(B1:B30) is the largest number of consecutive cells with negative
numbers.