rnegru
New Member
- Joined
- Jan 7, 2009
- Messages
- 8
Hello all,
I don't know if anyone has posted the same question yet, I am sorry but I haven't found it. I use an UDF to count the number of occurrences in any one cell for an inputed string. I have pasted below the code:
Function Count_Word(ByRef sInput As String, ByRef sWord As String) As Long
Dim lCount As Long
Dim lWhere As Long
Dim lWordLen As Long
lWordLen = Len(sWord)
lWhere = InStr(sInput, sWord)
Do While lWhere
lCount = lCount + 1
lWhere = InStr(lWhere + lWordLen, sInput, sWord)
Loop
Count_Word = lCount
End Function
Can anyone help me with a new UDF (or with modifying this one), so that I could count the occurrences of text in a range? I use Excel 2003, if that helps.
Thanks in advance,
Radu
I don't know if anyone has posted the same question yet, I am sorry but I haven't found it. I use an UDF to count the number of occurrences in any one cell for an inputed string. I have pasted below the code:
Function Count_Word(ByRef sInput As String, ByRef sWord As String) As Long
Dim lCount As Long
Dim lWhere As Long
Dim lWordLen As Long
lWordLen = Len(sWord)
lWhere = InStr(sInput, sWord)
Do While lWhere
lCount = lCount + 1
lWhere = InStr(lWhere + lWordLen, sInput, sWord)
Loop
Count_Word = lCount
End Function
Can anyone help me with a new UDF (or with modifying this one), so that I could count the occurrences of text in a range? I use Excel 2003, if that helps.
Thanks in advance,
Radu