View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default Count consecutive occurances

Here's a kludge:

Enter a zero in B1

Enter this formula in B2 and copy down as needed:

=IF(A2=0,0,IF(A3<A2,ROWS(B$1:B2)-IF(COUNT(B$1:B1),LOOKUP(2,1/ISNUMBER(B$1:B1),ROW(B$1:B1)),0),"0"))

Note that this formula will return both numeric 0's and *TEXT* 0's (that's
the kludge I mentioned!). Align the column right.

If that's not acceptable I can do this using a helper column with all
returns being numeric. Post back if you'd prefer that method.

Biff

wrote in message
ups.com...
I'm looking lo count the number of consecutive occurances of a 1
without a zero in a table but only if it is a new run. i.e.

Data Result
0 0
1 1
0 0
1 0
1 0
1 3
0 0