Try this UDF
Function CountWord(rng As Range, strWord As String, Optional CaseSensitive As Boolean = False)
Dim n As Long, ctr As Long
Dim strTemp As String, strLeft As String, strRight As String
If CaseSensitive Then
strTemp = rng
strWord = strWord
Else
strTemp = UCase(rng)
strWord = UCase(strWord)
End If
If InStr(1, strTemp, strWord) = 1 Then strTemp = " " & strTemp
ctr = (Len(strTemp) - Len(WorksheetFunction.Substitute(strTemp, strWord, ""))) / Len(strWord)
For n = 1 To ctr
strLeft = UCase(Mid(strTemp, InStr(1, strTemp, strWord) - 1, 1))
strRight = UCase(Mid(strTemp, InStr(1, strTemp, strWord) + Len(strWord), 1))
If ((Asc(strLeft) < 65 Or Asc(strLeft) > 90) And Not IsNumeric(strLeft)) _
And ((Asc(strRight) < 65 Or Asc(strRight) > 90) And Not IsNumeric(strRight)) Then
CountWord = CountWord + 1
End If
strTemp = Mid(strTemp, InStr(1, strTemp, strWord) + Len(strWord) + 1, 255)
If InStr(1, strTemp, strWord) = 1 Then strTemp = " " & strTemp
Next
End Function
Use like this
To make count case sensitive
This will count "(car)", "/car/", "car.", etc as instances of "car" and ignore "cartoon", "scarred", etc.
I have put a few options to search for in a dropdown in B1
I have not got the time just now to test this thoroughly, you might want to add some more conditions.
Hopefully this might give you a start for a UDF that meets your criteria.
Bookmarks