Excel - How to count a letter's occurences within a Cell

October 2017




Issue


Can you please let me know if there is a way where a particular text string can be counted within a value of a cell itself.

For example: A cell contains AAAABBBCCCAAA and I need to calculate occurrences of alphabet 'A' in this particular cell.

Solution


This should do the trick:

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


To find alphabet "B" or any other character, replace the "A" with the appropriate letter, or reference it to another cell where you can store the letter you are looking for, e.g.

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


where B1 now contains "A", or "C", etc.

Note


Thanks to WRL for this tip on the forum.
Published by aakai1056. Latest update on April 12, 2010 at 07:12 AM by aakai1056.
This document, titled "Excel - How to count a letter's occurences within a Cell," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).