count number of occurences within a string

G

Gabriel

Hello,

I want to count the number of "-" within a string like for instance
"abc-klm-xyz". There are two "-" characters. Is must be a function
that I don't know of.

Any suggestions?
Thanks in advance
Gabriel
 
D

Domenic

=SUMPRODUCT(--(ISNUMBER(SEARCH("-",MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))))

Hope this helps!
 
D

Domenic

Domenic said:
=SUMPRODUCT(--(ISNUMBER(SEARCH("-",MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))))

Hope this helps!

Or the much simpler...

=LEN(A1)-LEN(SUBSTITUTE(A1,"-","")
 

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