ThrottleWorks
Excel Ninja
I have downloaded & modified following code from http://www.cpearson.com/excel/wordcount.htm
but the code is giving me #Value! error.
Can someone please help me rectifying my error.
I have value in cell a5, the value is abc def efg.
I want to calculate no of words in cell a5.
Function CountWords()
Dim WordCount As Long
Dim Range("a4") As Range
Dim S As String
Dim N As Long
For Each Rng In Range
S = Application.WorksheetFunction.Trim(Rng.Text)
N = 0
If S <> vbNullString Then
N = Len(S) - Len(Replace(S, " ", "")) + 1
End If
WordCount = WordCount + N
Next Rng
MsgBox "Words In ActiveSheet Sheet: " & Format(WordCount, "#,##0")
End Function
but the code is giving me #Value! error.
Can someone please help me rectifying my error.
I have value in cell a5, the value is abc def efg.
I want to calculate no of words in cell a5.
Function CountWords()
Dim WordCount As Long
Dim Range("a4") As Range
Dim S As String
Dim N As Long
For Each Rng In Range
S = Application.WorksheetFunction.Trim(Rng.Text)
N = 0
If S <> vbNullString Then
N = Len(S) - Len(Replace(S, " ", "")) + 1
End If
WordCount = WordCount + N
Next Rng
MsgBox "Words In ActiveSheet Sheet: " & Format(WordCount, "#,##0")
End Function