InStrB method, just for counting one letter, is much faster than Split or Replace.
InStrB is faster than InStr, but requires extra tricks. In this case, (lngA And 1) to ensure we found a start of character.Code:Public Function CountLetters(ByRef Text As String, ByRef Letter As String) As Long Dim lngA As Long, strL As String * 1 strL = Letter strL = LCase$(strL) lngA = InStrB(Text, strL) Do While lngA > 0 CountLetters = CountLetters + (lngA And 1) lngA = InStrB(lngA + 1, Text, strL) Loop strL = UCase$(strL) lngA = InStrB(Text, strL) Do While lngA > 0 CountLetters = CountLetters + (lngA And 1) lngA = InStrB(lngA + 1, Text, strL) Loop End Function




Reply With Quote