Number of Occurrences of a String Value within a String

S

Stephen Allen

I am analysing some string data mostly for numeric values, but want to
remove those values that look like dates (e.g. 12/12/2008). Part of
the analysis means that I must count the number of occurrences on the
value "/" within the string.

Does anyone know of a function that would give me the count of the
number of instances of "/" or any other string portion?
 
G

Gary''s Student

With the text value in A1, use:

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

this will give the count of slashes in the cell.

NOTE the data must be text and not a Date nor formulaic divide
 
D

David Biddulph

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

Obviously the division by LEN("/") is unnecessary if the string portion you
are looking for is a single character, but it allows for the more general
case if you were looking for a longer string portion.
 

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