# Thread: Counting within a cell (97)

1. ## Counting within a cell (97)

Hello all,

Maybe I'm overlooking it, but I need a function that is doing the following:

I have cells filled with a character-code like "anfdggrnfhsoofk" And I need to know how often the letter 'n' is in this cell

Does this functions exist in Excel? and if not, how to solve it

2. ## Re: Counting within a cell (97)

If the text is in A1, the formula<pre>=SUM(1*(MID(A1,ROW(INDIRECT("1:"&LEN(A 1))),1)="n"))</pre>

entered as an array formula (confirm with Ctrl+Shift+Enter) should do what you want. You can replace "n" with the reference to a cell containing "n".

3. ## Re: Counting within a cell (97)

Assuming the text is in Cell A1 and you are looking for the letter 'n'..

=SUM(LEN(A1))-SUM(LEN(SUBSTITUTE(A1,"n","")))

Regards
Peter

4. ## Re: Counting within a cell (97)

Thanks,

It works perfectly

5. ## Re: Counting within a cell (97)

Peter,

There is no need for SUM...

=LEN(A1)-LEN(SUBSTITUTE(A1,"n",""))

should suffice.