F
F. Michael Miller
Can I do recursive functions in Excel?
I want a function to count the words in a cell [and I know I can do it with
=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1)], so I
tried the following:
Function CountWords(sSource As String) As Double
Dim sPhrase As String
Dim dWords As Double
dWords = 0
sPhrase = Trim(sSource)
If Len(sPhrase) = 0 Then
dWords = 0
Else
dWords = dWords + CountWords(Right(sPhrase, Len(sPhrase) - Find(" ",
sPhrase, 1)))
End If
CountWords = dWords
End Function
I get the following error when I try to compile:
Compile Error: Ambiguous name detected: CountWords.
Thanks!
I want a function to count the words in a cell [and I know I can do it with
=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1)], so I
tried the following:
Function CountWords(sSource As String) As Double
Dim sPhrase As String
Dim dWords As Double
dWords = 0
sPhrase = Trim(sSource)
If Len(sPhrase) = 0 Then
dWords = 0
Else
dWords = dWords + CountWords(Right(sPhrase, Len(sPhrase) - Find(" ",
sPhrase, 1)))
End If
CountWords = dWords
End Function
I get the following error when I try to compile:
Compile Error: Ambiguous name detected: CountWords.
Thanks!