Quote:
Originally Posted by kebo
a way to count occurences of one string inside of another:
Dim S As String
Dim position As Long
Dim SearchString As String
Dim count As Long
S = " This is a great sentence. It is not very long, but is also quite lame. It is however unimportant and is not very exciting"
SearchString = "is"
count = 0
position = InStr(S, SearchString)
Do Until position = 0
count = count + 1
position = InStr(position + 1, S, SearchString)
Loop
debug.print count
End Sub
its not fully tested but seems to work
kevin
|
everytime i try to print count it gives me "0"