LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default 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)

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Text Strings Kholm Excel Worksheet Functions 11 August 21st 07 05:56 PM
Counting strings in excel with Pivot navin Excel Discussion (Misc queries) 4 January 3rd 07 02:17 PM
Counting Text Strings With Conditions [email protected] Excel Discussion (Misc queries) 2 July 15th 06 08:05 PM
Counting text strings 525047 Excel Worksheet Functions 1 April 21st 06 05:35 AM
counting unique strings Sparky Mark Excel Discussion (Misc queries) 3 January 20th 05 11:47 PM


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"