Counting multiple occurances within a cell

G

Guest

Is there a way to count multiple occurances of a string within a single cell?
As an example, Cell A1 conatins the string "ST,CN,ST" I want to know the number of times "ST" was found in the cell. I also want to continue down the row and continue counting occurances.
 
H

Harlan Grove

John Diem said:
Is there a way to count multiple occurances of a string within a
single cell? As an example, Cell A1 conatins the string "ST,CN,ST"
I want to know the number of times "ST" was found in the cell. I
also want to continue down the row and continue counting occurances.

In general,

=(LEN(string)-LEN(SUBSTITUTE(string,substring,""))/LEN(substring)

To count all instances of "ST" in each cell in B2:D9,

=SUMPRODUCT(LEN(B2:D9)-LEN(SUBSTITUTE(B2:D9,"ST","")))/LEN("ST")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top