View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Luke M Luke M is offline
external usenet poster
 
Posts: 2,722
Default How do I create a function that counts number of cells in a series

Create a helper column (B).
In B2:
=IF(A2="P",0,B1+1)

Now, to get your desired answers
2s:
=COUNTIF(B:B,2)
3s:
=COUNTIF(B:B,3)
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Demosthenes" wrote:

For example, suppose you have the following data:

P
S
S
P
S
S
S
P
S
S

and you want to count how many "S"s repeat after each "P." That is, you're
looking for output:

"2s" = 2
"3s" = 1

Is there any way to write a function to do that?