Count of Words in a Cell by UDF

Function for counting words in a cell excluding space (ready vba code just copy , paste and run)

Function COUNTWORDS(Text_String As String) As Integer
'User define function counts the number of words in a cell exclude space
'www.anilnahar.com
String_Length = Len(Text_String)
For Current_Character = 1 To String_Length
COUNTWORDS = 0
Dim String_Length As Integer
Dim Current_Character As Integer
If (Mid(Text_String, Current_Character, 1)) = " " Then
COUNTWORDS = COUNTWORDS + 1
End If
Next Current_Character
End Function

Share this post

Post Comment

two × three =