Counting consecutive strings of text
Hi Sam
I am assuming you have only two text string in this column. Suppose you have
data as below starting from cell A1
ColA
Seagrass
Seagrass
Seagrass
Seagrass
NA
NA
NA
Seagrass
Seagrass
Seagrass
NA
Seagrass
Seagrass
Seagrass
NA
Seagrass
Seagrass
Seagrass
NA
Seagrass
Seagrass
NA
Try the below array formula and copy down as required...An array formula can
perform multiple calculations and then return either a single result or
multiple results. You create array formulas in the same way that you create
other formulas, except you press CTRL+SHIFT+ENTER to enter the formula. If
successful in 'Formula Bar' you can notice the curly braces at both ends like
"{=<formula}"
=SMALL(IF($A$1:$A$100<$A$2:$A$101,ROW($A$1:$A$100 )),ROW(A1)*2-1)-
IF(ROW(A1)=1,0,SMALL(IF($A$1:$A$100<$A$2:$A$101,
ROW($A$1:$A$100)),ROW(A1)*2-2))
The result should be as below..
4
3
3
3
2
#NUM!
#NUM!
#NUM!
To handle the error returned try the below version (again array entered)
=IF(ISERROR(SMALL(IF($A$1:$A$100<$A$2:$A$101,ROW( $A$1:$A$100)),
ROW(A1)*2-1)),"",SMALL(IF($A$1:$A$100<$A$2:$A$101,
ROW($A$1:$A$100)),ROW(A1)*2-1)-IF(ROW(A1)=1,0,
SMALL(IF($A$1:$A$100<$A$2:$A$101,ROW($A$1:$A$100) ),ROW(A1)*2-2)))
--
Jacob
"SamG" wrote:
Hi I want to count the number of consecutive strings of text in a column
where the text string will be indispersed by something like "NA":
Seagrass
Seagrass
Seagrass
Seagrass
NA
NA
Seagrass
Seagrass
..
I want to count the number of times Seagrass appears before a break of NA's
then count the next string of Seagrass. Presumably I would have a couple of
cells as a result (in this case 4 & 2)
|