Count occurrences of specific characters in an Excel cell
This tutorial introduces how to apply formulas based on the LEN and SUSTITUTE functions to count the number of times a specific character appears in an Excel cell.
How to count number of specific characters in a cell?
Cell_ref: The cell contains the text you will count specific character inside. You also can directly replace the cell_ref with text enclosed in quotation marks;
Character: The character you want to count. It can be:
1. The character enclosed in quotation marks;
2. Or a reference to a cell containing the character.
How to use this formula?
1. Select a blank cell, copy the below formula into it to get the result.
In this case, it returns the result 3, which means that the character “e” appears three times in B3.
Tips: You can directly reference the character cell in the formula as below. After getting the first result, drag the Fill Handle to apply the formula to other cells.
- 1. If the specific character is not found, it will return 0;
- 2. The SUBSTITUTE function is case-sensitive;
- 3. If you want to count specific character in a cell and ignore the case, please use the UPPER function inside the SUBSTITUTE as the below formula shown:
How this formula works?
- 1. LEN(B3): This LEN function calculates the total text length of B3 and returns the result 20.
- 2. LEN(SUBSTITUTE(B3,"e","")): The SUBSTITUTE function removes the character “e” from cell B3, and then the LEN function calculates the text length for cell B3 without the specific character “e”. Here the result is 17;
- 3. Finally the text length without character “e” is subtracted from the total text length of the original text string and get the total count of “e” in cell B3 (20-17=3).
Excel LEN function
The LEN function returns the number of characters in a text string.
Excel SUBSTITUTE function
The SUBSTITUTE function replaces text or characters within a text string with another text or characters.
The Best Office Productivity Tools
Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.
- Designed for 1500 work scenarios, helps you solve 80% Excel problems.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
- Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
- 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.