Skip to content

Instantly share code, notes, and snippets.

@KirillPashkov
Last active November 30, 2017 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KirillPashkov/892df37d574624ca66f79c9d58fe575b to your computer and use it in GitHub Desktop.
Save KirillPashkov/892df37d574624ca66f79c9d58fe575b to your computer and use it in GitHub Desktop.
Find = chr(34)
Str = "This is string with " & chr(34) & "double quotes" & chr(34) & "."
Occurrences = (Len(Str) - Len(Replace(Str,Find,Empty)) / Len(Find))
MsgBox "String: " & Str & vbCrLf &_
"Contains :" & Occurrences & " occurrences of: " & Find & "."
Function GetOccurrences(InputString,LookupString)
If _
IsNull(InputString) Or IsEmpty(InputString) Or _
IsNull(LookupString) Or IsEmpty(LookupString) _
Then
GetOccurrences = 0
Else
If Len(InputString) = 0 Or Len(LookupString) = 0 Then
GetOccurrences = 0
Else
GetOccurrences = (Len(InputString) - Len(Replace(InputString,LookupString,Empty)) / Len(LookupString))
End If
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment