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,"-","")
 
Top