Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In a column, Counting successive cells

Status
Not open for further replies.
Jan 17, 2012
2
EG
I have a column with values of 0 and 1.

I need to count the number of cells containing 1 between cells containing 0

Is there a conditional count or sum formula to get this result in the cell next to each 0

Example:

A B
0 3
1
1
1
0 2
1
1
0 5
1
1
1
1
1
0
and so on
 


hi,

assume your data starts in row 2. Row 1 must be empty for reference.

This is a grouping column
[tt]
B2: =IF(A2=0,B1+1,B1)
[/tt]
This is the display column
[tt]
C2: =IF(A2=0,COUNTIF(B:B,B2)-1,"")
[/tt]
Copy the formulas down.


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top