What is the easiest way to count the number of specific charecters in a cell.
e.g = Cell A1 = Dog Cat Animal
number of As = 2
number of Spaces =2
number of Ds = 1
etc.
any help will be much appreciated.
Thanks,
Rennie
What is the easiest way to count the number of specific charecters in a cell.
e.g = Cell A1 = Dog Cat Animal
number of As = 2
number of Spaces =2
number of Ds = 1
etc.
any help will be much appreciated.
Thanks,
Rennie
This function should do the job
Function CountChar(CellRef As Range, CharSearch As String)
Dim c
Dim CharCount
CharCount = 0
For c = 1 To Len(CellRef.Value)
If Mid(CellRef, c, 1) = CharSearch Then
CharCount = CharCount + 1
End If
Next c
CountChar = CharCount
End Function
I haven't tested on different types of data. Works on your example.
:guitar:TextBlackTextRedTextYellow
Excellent work Neale. Thank you
Hi Rennie
Not to take anything away from Neals excellent help, you can also use:
=LEN(A1)-LEN(SUBSTITUTE(UPPER(A1)," ",""))
=LEN(A2)-LEN(SUBSTITUTE(UPPER(A2),"A",""))
=LEN(A3)-LEN(SUBSTITUTE(UPPER(A3),"D",""))
To get a count of specific characters.
Thankk you Dave I appreciate your help.
Don’t have an account yet? Register yourself now and be a part of our community!