Want to know how many characters there are in a certain cell? This tutorial will help you choose an Excel formula for character count best suited for your particular case.
Initially, Excel was designed to work with numbers. Fortunately, the developers of this helpful application didn't forget about text. Below, you'll find a number of formulas for counting characters in Excel. Just look through the examples and see which one best suits your needs.
Here are the cases we are going to cover:
Excel formula to count the number of characters in a cell
First things first, let's solve the most common case. To find how many characters there are in an Excel cell, the formula is as simple as:
For example, to count characters in each cell of column A beginning in A3, this is what you need to do:
- Enter the below formula in any empty cell in row 3:
=LEN(A3)
- Double-click the fill handle to get the formula copied across the whole column.
Done!
Feel free to use this formula each time you need to count the number of characters in a string.
Note. Please pay attention that the Excel LEN function counts absolutely all characters in a cell, including letters, numbers, punctuation marks, special symbols, and all spaces (leading, trailing and spaces between words).
Count characters in a range of cells
To get the total of characters in an Excel range, you can use the LEN function together with SUMPRODUCT:
And your real-life formula may look similar to this:
=SUMPRODUCT(LEN(A3:A18))
Another way to count all characters in a range is using LEN in combination with the SUM function:
=SUM(LEN(A3:A18))
Unlike SUMPRODUCT, the SUM function does not process arrays by default, so you need to press Ctrl + Shift + Enter to turn it into an array formula in Excel 2019 and earlier. In Excel 365 and 2021, it works as a regular formula due to inbuilt support for dynamic arrays.
How this formula works:
The logic is very simple. The LEN function calculates the string length for each individual cell in the specified range and returns an array of numbers. And then, SUMPRODUCT or SUM adds up those numbers and returns the total character count.
How to count specific characters in a cell
To find out how many times a given character appears in a cell, the generic formula is:
Suppose you maintain a database of items where each item type has its own unique identifier. And each cell contains several items separated by comma, space, or any other delimiter. The task is to get the number of occurrences of a certain unique identifier in each cell.
Assuming the list of items is in column A beginning in A3, and the target character is in column B in the same row, the formula is as follows:
=LEN(A3) - LEN(SUBSTITUTE(A3, B3, ""))
Note. Excel's SUBSTITUTE is a case-sensitive function, and therefore the above formula treats uppercase and lowercase letters as different characters. For example, cell A4 in the screenshot above contains one occurrence of "a" and two occurrences of "A". The formula counted only the uppercase "A" and returned 2 as the result.
How this formula works:
To understand the formula's logic, let's break it down into smaller parts:
- First, you find the total string length in cell A3 with:
LEN(A3)
- Then, you remove all occurrences of the letter "A" in A3 by replacing it with an empty string:
SUBSTITUTE(A3, "A", "")
- The next step is to find the string length without the letter "A":
LEN(SUBSTITUTE(A3, "A", ""))
- Finally, you subtract the length of the string without "A" from the total length string:
LEN(A3) - LEN(SUBSTITUTE(A3, B3, ""))
As the result, you get the count of "removed" characters, which is the number of occurrences of that particular character in the cell.
Case-insensitive formula to count letters in Excel cell
When counting letters in Excel cells, you may sometimes need a formula that ignores the letter case. To make such a formula, use the UPPER function inside SUBSTITUTE to convert a given letter to uppercase before running the substitution.
For example, to count both "A" and "a" in cell A3, use this formula:
=LEN(A3) - LEN(SUBSTITUTE(UPPER(A3), "A", ""))
The LOWER function will also do:
=LEN(A3) - LEN(SUBSTITUTE(LOWER(A3), "a", ""))
A slightly more complex way is using nested SUBSTITUTE functions:
=LEN(A3) - LEN(SUBSTITUTE(SUBSTITUTE (A3, "A", ""), "a", "")
In our data set, the letters to be counted are input in column B, so we convert both the source cell and the cell containing the character to uppercase:
=LEN(A3) - LEN(SUBSTITUTE(UPPER(A3), UPPER(B3),""))
And this works beautifully irrespective of the target letter's case:
How to count certain text/substring in a cell
If you want to know how many times a certain combination of characters appears in a given cell (e.g. "C2" or "C-2" or "cat"), then divide the characters count by the length of the substring.
Case-sensitive formula:
=(LEN(A3) - LEN(SUBSTITUTE(A3, B3, ""))) / LEN(B3)
Case-insensitive formula:
=(LEN(A3)-LEN(SUBSTITUTE(UPPER(A3), UPPER(B3),""))) / LEN(B3)
Where A3 is the original text string and B3 is the substring to count.
For the detailed explanation of the formula, please see How to count specific text / words in a cell.
How to count specific characters in a range
Knowing a formula for counting certain characters in a single cell, it's quite easy to modify it a little further to count the number of occurrences of a given character in several cells. For this, just place the LEN formula inside the SUMPRODUCT function that can handle arrays:
For example, to get to know how many times the character in D2 occurs in the range A3:A18, the formula is:
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(A3:A18, D2, "")))
Instead of SUMPRODUCT, you can also use SUM:
=SUM(LEN(A3:A18) - LEN(SUBSTITUTE(A3:A18, D2, "")))
But this formula requires pressing Ctrl + Shift + Enter because, in all versions other than Excel 365 and 2021, SUM can handle arrays only in an array formula.
How this formula works:
The SUBSTITUTE function replaces all occurrences of a given character ("A" in this example) with an empty string ("").
The text string returned by SUBSTITUTE is served to the LEN function so it calculates the string length without A's.
The string length without A's is subtracted from the total length of the original string. The result is an array of character counts per cell.
Finally, SUMPRODUCT sums the numbers in the array and returns the total character count in the range.
Case-insensitive formula to count letters in a range
To create a case-insensitive formula for counting specific characters in a range, follow the same approaches that we used for counting certain letters in a cell regardless of the text case.
Use the UPPER function and supply an uppercase letter:
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(UPPER(A3:A18), "A", "")))
Use the LOWER function and supply a lowercase letter:
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(LOWER(A3:A18), "a", "")))
Nest a couple of SUBSTITUTE functions one into another:
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(SUBSTITUTE((A3:A18), "A", ""), "a", "")))
In the character of interest is input in a predefined cell, UPPER or LOWER will work equally well:
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(UPPER(A3:A18), UPPER(D2), "")))
Or
=SUMPRODUCT(LEN(A3:A18) - LEN(SUBSTITUTE(LOWER(A3:A18), LOWER(D2), "")))
The below screenshot shows it in action:
How to count certain text / substring in a range
To count the number of occurrences of certain text in a range, use this generic formula:
For example, to count the number of times the word "Life" appears in the range A3:A18, the formula is:
=SUMPRODUCT((LEN(A3:A18) - LEN(SUBSTITUTE(A3:A18, D2, ""))) / LEN(D2))
In the above screenshot, only the word "Life" is counted, but not "life". However, you can force the formula to disregard the letter case with the help of either the UPPER or LOWER function. To see how this works, please visit How to count specific words in a range.
Excel character limits for cells
Microsoft Excel has a limitation on the number of characters that can be entered in a cell. If you have worksheets with large amount of text data, you may find the following information helpful.
- The total number of characters that a cell can contain is 32,767.
- A cell can only display 1,024 characters. At the same time, the Formula bar can show all 32,767 symbols.
- The maximum length of a formula is 8,192 characters in Excel 2007 and higher (1,014 in Excel 2003).
Please consider the facts when you are going to merge or import data from an external source.
These are the best practices for counting characters in Excel. For first-hand experience, you can download a sample workbook and check out a list of related resources at the end of the page. Thank you for reading and hope to see you soon!
Practice workbook for download
Count characters in Excel - formula examples (.xlsx file)
147 comments
ANY HELP FOR USING FORMULA "COUNT IF" FOR SPECIFIED CELL WHICH CONTAIN MORE THAN 255 LETTER
Can you help?
I want to display the names of anyone with a "C" in a range of cells. So if any cells from A1:A10 has a "C" then A12 needs to display the name that is in cell A11, If there is not a "C" then no name will be displayed..
Thank you!!
I have past my data in one cell for E.g cell A2 1.aaaaa
2.bbbbb
3.ccccc
I want to apply formula for calculate the no of Pointer mention in one cell can any one suggest me how to drived No. .....
how to count different alphabet if many rows..
example:
H2=JLT
I2=JLT
J2=#N/A
H3=PPR
I3=PPR
J3=#N/A
Dear Svetlana,
i have a small query, i have a attendance sheet like below:-
Name Code 01-Dec 02-Dec 03-Dec 04-Dec 05-Dec 06-Dec 07-Dec Total C/L
xxxx xx P 3/4 C/L P 1/2 C/L; 1/2 S/L C/L W/O P ?
i want to count total C/L, but in this numaric data is there with C/L.
pls suggest.
thanks in advance.
Rajesh
Hi Maria,
Hope you are doing well, I am a basic excel user, I am handling an excel work book in 2016 version, I've got a query as follows:
I have 9 worksheets in an excel book and a specific column in each sheet which displays a series of reference numbers as:
GAD5-CDC-T2-349-230315-DWG-PP-STR-0114-0
GAD5-MGM-T2-349-230315-DWG-PP-STR-0114-0
GAD5-CDC-T2-349-230315-DWG-SD-STR-0114-0
GAD5-MGM-T2-363-250315-DWG-PP-STR-0119-0
GAD5-CDC-T2-363-250315-DWG-DD-STR-0119-0
GAD5-CDC-T2-363-250315-DWG-BD-STR-0119-0
GAD5-CDC-T2-259-51-050515-DWG-FD-S-0233-00
GAD5-CDC-T2-259-51-050515-DWG-TD-S-0233-00
GAD5-MGM-T2-259-51-050515-DWG-LD-S-0233-00
GAD5-MGM-T3-119-25-DDS-ST-1568-02
GAD5-MGM-T3-119-25-DDS-RT-1568-02
GAD5-MGM-T3-119-25-DDS-OT-1568-02
and so on, Please note: these numbers are not following any sequence. I want to count the number of times the second last series of number is appearing. In this Instance
0114 is 3 times
0119 is 3 times
0233 is 3 times &
1568 is 3 times
I want to count this by a formula and get the result in any other cell as a counter. I'll appreciate if you could help me in this please.
Hi Syed,
You should use the following formula to count all cells with "0114":
=CONCATENATE("0114 is ", SUMPRODUCT((MID(A1:A12, FIND("-", A1:A12, LEN(A1:A12) - 8) + 1, 4) = "0114") * 1), " times")
You can change this formula and use it to count cells with "0119", "0233", etc.
hey i want to do the validation of PAN no. i.e. in between first five char are alfabets, next four are numeric & last one is also alfabet. its total 10 digit of no. so how can I check multiple PAN nos. at one tym. please tell me the formula.
Hi dinesh,
You should use the following formula:
=AND(NOT(ISERROR(SUMPRODUCT(SEARCH(MID(LEFT(A1, 5),ROW(INDIRECT("1:"&LEN(LEFT(A1, 5)))),1),"abcdefghijklmnopqrstuvwxyz")))), NOT(ISERROR(VALUE(MID(A1, 6, 4)))), NOT(ISERROR(SUMPRODUCT(SEARCH(MID(RIGHT(A1, 1),ROW(INDIRECT("1:"&LEN(RIGHT(A1, 1)))),1),"abcdefghijklmnopqrstuvwxyz")))))
Hello all, need a help i have text with drop down as follows in a cell
5(Deliverables as per requirement)
4(Deliverables with minor/cosmetic defects/bugs)
3(Deliverables with minor/cosmetic defects/bugs but affected overall schedule)
2(Deliverables with major defects/bugs)
1(Deliverables with critical defects/bugs affected customer quality and schedule)
i have different milestones(rows) with above drop down option now i want to sum all points for all rows.please let me know how SUM related cell consider above in numbers not text
Hi Puran,
You should use the following formulas:
=SUMPRODUCT((LEFT($A$1:$A$15, 1)="5") * 1)
=SUMPRODUCT((LEFT($A$1:$A$15, 1)="4") * 1)
=SUMPRODUCT((LEFT($A$1:$A$15, 1)="3") * 1)
=SUMPRODUCT((LEFT($A$1:$A$15, 1)="2") * 1)
=SUMPRODUCT((LEFT($A$1:$A$15, 1)="1") * 1)
Please replace "$A$1:$A$15" with your own range.
Hi,
I have looked at all of the above and I am still lost and can only find the outcome of one piece of the calculation
=COUNTIF(O8:O17,"24+") etc
I would like excel to count the number of times the Age Group occurs and also the corresponding value when it comes up in the total. For example:
The below shows the number of times each age range is repeated, however, It does not match the number of Apps required. I need it to add the corresponding value.
"No. of Apps
required " Age Group
1 16-18
1 16-18
1 16-18
1 16-18
1 16-18
1 24+
13 24+
1 16-18
1 18+
1 19+
1 16-18
Total
16-18 7
18 1
19+ 1
24+ 2
Apps req 23
So the outcome I am hoping to achieve is the sum of all group matches the sum of apps req.
Total
16-18 7
18 1
19+ 1
24+ 14
Apps req 23
Can you help?
Hi Donaly,
You should use the following formulas:
=SUMPRODUCT((B1:B11="16-18") * A1:A11)
=SUMPRODUCT((B1:B11="18") * A1:A11)
=SUMPRODUCT((B1:B11="19+") * A1:A11)
=SUMPRODUCT((B1:B11="24+") * A1:A11)
If the "No. of Apps required" data are in B1:B11 and "Age Group" are in A1:A11.
Hi
I am trying to figure out how to combine a couple of countif's from two different columns to give me the answer in another cell.
Eg:
=COUNTIF(F5:F99; "*Red*") (so how many times"Red" is written in this particular series BUT i only want to know which "Red"s belong to a specific gender e.g this countif =COUNTIF(E5:E99; "*f*").
I can't figure out how to combine them to prouduce a result that gives me all the 'f' in the columns E which are also "red"
Would love your help.
Thank you :)
Hi Trudie,
You should use the following formula:
=COUNTIFS(F5:F99, "*red*", E5:E99, "*f*")
Vehicle Name Total KM
Santro 15km
Tavera 13km
Swift 40km
Indica 30km
Hi, I am trying to format a cell if it contains EXACTLY 17 characters. I input Vehicle VIN numbers which contain letters & numbers, 17 ONLY.
I need the cell to change color IF it has 17 characters. (Cells A2 thru A29
Hi ALLISON,
Please try to do the following:
1. Select cells A2:A29.
3. Click Conditional Formatting -> New Rule.
4. Select the "Use a formula to determine which cells to format".
5. In the Formula field type the following formula:
=LEN(A2)=17
6. Click the Format button to set the format you need.
7. Click OK.
Hi,
I have a cells with numbers and characters i.e. 2C, 5B. Please could you tell me the calculation to count up just the numbers and then seperately the characters?
Many thanks
Hi
successfully I can get the count of repeated text in a range for example: I have a repeated letter "P" in the range A21:D123 50 times the function I made = sum(len(A21:D123)this will count successfully all text in this range .
I am struggling in counting the occurrences of different letters in the same range what I need is to count the "P" individually and at the same time if there are A, C and N I also need their numbers in the same range. how can I do this?
thanks in advance
Dear Sir,
How to find out the position of a word in a text string in excel 2013.
Example.
Cell A1
The cow has eaten the grass.
Position of the word "cow" is 2.
Position of the word "eaten" is 4.
Position of the word "grass" is 6.
Regards
S.Narasimhan
i have three option in A column present, leave , late i whant if present or leave = 0 and if late then 20 add total of month.
How can I count unique values among duplicates in a column? I have text that is duplicated on several rows. I need a total count of all text without counting duplicates.
Hi Carol,
Please check out the following examples:
How to count unique values in Excel
I have a excel of 4 columns and 90 rows, i want to compare this with another column having 180 rows and hence count the common in this 4 rows
Hello!
Just wanna how can I count a number which is double number, I have this numbers (1,2,3,4,5,11,23) and my problem was, the double number was counted separately. Instead of 7 it counted 9.
Thank you very much!
Some of the characters that have been written on the column if the column will come lekhata