ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   count number of occurences within a string (https://www.excelbanter.com/excel-worksheet-functions/7086-count-number-occurences-within-string.html)

Gabriel

count number of occurences within a string
 
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

Domenic


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

Hope this helps!

Gabriel Wrote:
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



--
Domenic
------------------------------------------------------------------------
Domenic's Profile: http://www.excelforum.com/member.php...o&userid=10785
View this thread: http://www.excelforum.com/showthread...hreadid=320408


Domenic


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

Hope this helps!


Or the much simpler...

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


--
Domenic
------------------------------------------------------------------------
Domenic's Profile: http://www.excelforum.com/member.php...o&userid=10785
View this thread: http://www.excelforum.com/showthread...hreadid=320408



All times are GMT +1. The time now is 09:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com