Count String Occurances
Count the number of string occurrences inside another string.
Public Function Count(Source As String, Countee As String) As Long
Dim I As Long, iCount As Integer
iCount = 0
I = 1
Do
If (I > Len(Source)) Then Exit Do
I = InStr(I, Source, Countee, vbTextCompare)
If I Then
iCount = iCount + 1
I = I + 1
DoEvents
End If
Loop While I
sCount = iCount
Exit Function
CountError:
sCount = 0
Exit Function
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.