View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chaplain Doug Chaplain Doug is offline
external usenet poster
 
Posts: 127
Default How to Count String occurences

Thanks for the cool tip. Did you guys study mathematics? I've got degrees
in it, but my doltish brain didn't think of this. I AM getting old! God
bless.

"Chip Pearson" wrote:

Try something like the following:


Dim S As String
Dim SearchString As String
Dim SubStringCount As Integer
S = "the quick brown fox"
SearchString = " " ' two spaces
SubStringCount = (Len(S) - Len(Replace(S, SearchString, ""))) /
Len(SearchString)
Debug.Print SubStringCount


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





"Chaplain Doug" wrote in
message
...
Excel 2003. Is there a quick way (a function perhaps) to count
the number of
occurences of a substring within a string? I have address
strings in which I
want to quickly count the number of occurences of a double
space (" ") in
the string. Thanks for the help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org