I have a list of codes. Some of these codes have one dash in them, others two, some with one space, some with two or more. I would like to run a function that would count how many dashes (or how many spaces) are in a code.
If you wanted a formula to tell you how many dashes were in a code then:
=LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))
would do it.
Likewise, to see how many spaces were in a code, then:
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))
would do it.
To count how many spaces or dashes were in a code:
=(LEN(A1)-LEN(SUBSTITUTE(A1,"-","")))+(LEN(A1)-LEN(SUBSTITUTE(A1," ","")))
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.