Counting a series of text and/or numbers within columns
Try these array formulas** :
Count 2 consecutive Ws:
=SUM(--(FREQUENCY(IF(B2:B9="w",ROW(B2:B9)),IF(B2:B9<"w", ROW(B2:B9)))=2))
Count 3 consecutive 0s. Assumes no empty cells within the range. Empty cells
evaluate as 0 and could cause incorrect results. If there might be empty
cells the formula can be tweaked to account for them.
=SUM(--(FREQUENCY(IF(A2:A9=0,ROW(A2:A9)),IF(A2:A9<0,ROW( A2:A9)))=3))
Note that these formulas are explicit in how they count.
W
W
W
W
That would not be counted as 2 instances of 2 consecutive Ws. That is
considered 1 instance of 4 consecutive Ws.
** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)
--
Biff
Microsoft Excel MVP
"andrew" wrote in message
...
I have the following table:
A B
0 W
1 W
0 D
0 W
0 D
1 W
0 W
1 D
Is there a way to count or sum up a series of text or number within a
column? E.g.
i) count the number of times the alphabet W appears in sequence of 2 times
(i.e. B2 and B3 in a column)? Table above shows W appearing twice in
sequence.
ii) count the number of times the number zero (0) appears in a sequence of
3
times within a column?
Appreciate any help, thanks!
|