How to Count Specific Characters in a Cell (String) in Excel

Count specific characters in a cell

Excel formula: Count specific characters in a cell
=LEN(a1)-LEN(SUBSTITUTE(a1,txt,""))
If you need to count how many times a specific character appears in a cell, you can do so with a formula that uses SUBSTITUTE and LEN. In the generic form of the formula above, a1 represents the cell address, and txt represents the character that you want to count.
In the example, the active cell contains this formula:
=LEN(B3)-LEN(SUBSTITUTE(B3,C3,""))
This formula works by using SUBSTITUTE to first remove all of the characters being counted in the source text. Then the length of the text (with the character removed) is subtracted from the length of the original text. The result is the number of characters that were removed with SUBSTITUTE, which is equal to the count of those characters.
SUBSTITUTE is a case sensitive function, so it will match case when running a substitution. If you need to count both upper and lower case occurrences of a specific character, use the UPPER function inside SUBSTITUTE to convert the text to uppercase before running the substitution. Then supply an uppercase character as the text that's being substituted.
=LEN(B3)-LEN(SUBSTITUTE(UPPER(B3),C3,""))