character count

G

Guest

I seem to have misplaced a function.


What is hte method for counting how many times a specific character occurs
inside a string without looping through it?
eg...

a = FUCNTIONCHARSEARCH("The quick brown fox ran over the yard.","t")
a = 2


?
 
C

Chip Pearson

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

or in VBA

Dim L As Long
Dim S As String
S = "abcda"
L = Len(S) - Len(Replace(S, "a", ""))
Debug.Print L


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"ben" <&&&&[email protected](remove this if mailing direct)>
wrote in message
news:[email protected]...
 

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