De vez em quando somos surpreendido com a necessidade de verificarmos quantas vezes certo caracter aparece numa palavra, frase, uo texto.
Aqui você o começo deste estudo...Divirta-se!
Public Function CountStringOccurrence ( _ByVal strString As String, _ByVal strCharString As String, _Optional ByVal blnCase As Boolean = True) As Long
Dim lngPosition As Long, lngLen As Long, lngCount As LongLet lngCount = 0Let lngLen = Len(strCharString)If blnCase = False Then' Search is to be case-insensitive, so convert both the character string' and the string being searched to upper case charactersLet strString = UCase(strString)Let strCharString = UCase(strCharString)End IfFor lngPosition = 1 To Len(strString) - lngLen + 1' If the desired character string is found, increment the counterIf StrComp (Mid(strString, lngPosition, lngLen), _strCharString, vbBinaryCompare) = 0 _Then lngCount = Let lngCount + 1Next lngPositionCountStringOccurrence = lngCountExit Function
End Function