If you want to count specific characters within the worksheet, the LINE and SUBSTITUTE functions can be joined together. This allows you to count a certain character in a string or range of cells with minimum effort.
Counting Characters in a Single Cell: Suppose you are interested in determining the number of times a particular character occurs in a single cell (let us assume it is cell A1). The following formula may come in handy:
=LEN(A1) - LEN(SUBSTITUTE(A1, "a", ""))
In this formula, you need to substitute "a" with a counted character in the text. The original text's length is obtained through the function LEN(A1), while the length after erasing a particular character is obtained using the formula LEN(SUBSTITUTE(A1, "a,")). The difference obtained enables you to get the total number of that particular character.
How to Count Characters in a Range of Cells: To do so, a range (e.g., A1
) will include more than one character and include either an array formula or the SUMPRODUCT function:
=SUMPRODUCT(LEN(A1:A10) - LEN(SUBSTITUTE(A1:A10, "a", "")))
The results from each cell out of the specified range are counted and added together.
Effective Use Suggestions:
Remember to omit "a" to substitute with the character to be counted.
You can change the range provided in the formula to suit your data set.
If the character is a space or any other character that is not an alphanumeric type, ensure the right one is used in quotes.
Google Sheets will use the above formulas whenever text data needs to be treated, and the number of letters present in it will be determined.