How to Count Cells by Text Length Using LEN in Excel
Question details
The user needs to count the number of cells in a specific range where the text length is greater than a certain number of characters (e.g., 8 characters).

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Attempting to count cells based on their character count using a COUNTIF-style criteria combined with the LEN function.
- Observed behavior
- Using a formula like COUNTIF(A:A, LEN(A1)&">8") fails because COUNTIF does not evaluate the LEN function separately for every cell in the array.
Ensure your data range does not contain unexpected trailing spaces, as these are counted as characters by the LEN function. Consider using the TRIM function first if your data is imported from external sources.
Use SUM and LEN as an Array Formula
Since COUNTIF cannot process arrays dynamically with the LEN function, use SUM combined with a logical comparison and double unary operator to force the calculation.
The LEN function evaluates the length of each cell in the range, creating an array of numbers. The >8 comparison converts these numbers to TRUE or FALSE. The double negative (--) coerces these boolean values into 1s and 0s, which the SUM function then adds together to give the final count.
Click on the empty cell where you want the final character count result to appear.
Type the formula =SUM(--(LEN(A1:A10)>8)) into the formula bar. Adjust the range A1:A10 and the condition >8 to match your specific dataset.
Press Enter to calculate. If you are using Excel 2019 or older, press Ctrl + Shift + Enter to apply it as an array formula.

Use SUMPRODUCT with LEN to Avoid Array Confirmation
SUMPRODUCT inherently handles arrays without requiring Ctrl+Shift+Enter in older versions of Excel, making it a more versatile alternative.
Easily Calculate and Analyze Data with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array formulas, SUMPRODUCT, and LEN functions, allowing you to seamlessly calculate cell counts based on text length. It offers an intuitive interface and high compatibility with complex Excel formulas.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open the workbook containing the text data you want to measure.
- 2. Select the result cell: Click on an empty cell where you want to display the total count.
- 3. Input the array formula: Type =SUMPRODUCT(--(LEN(A1:A10)>8)) into the formula bar, replacing A1:A10 with your actual data range.
- 4. Get your result: Press Enter. WPS Spreadsheet processes the array natively and displays the accurate count instantly.

Frequently Asked Questions
Why doesn't COUNTIF work with the LEN function directly?
The COUNTIF function requires an actual range reference (like A1:A10) as its first argument. It cannot process a manipulated array in memory, which is what the LEN function generates when applied to a range. Therefore, functions like SUM or SUMPRODUCT must be used to handle the array.
Can I use wildcard characters in COUNTIF to count string length?
Yes, if you want a simple alternative to count cells with an exact number of characters, you can use question marks. For example, =COUNTIF(A1:A10, "?????") counts cells with exactly 5 characters. However, this is impractical for 'greater than' conditions, which is why the LEN and SUMPRODUCT method is preferred.
How do I count cells with text length between 5 and 10 characters?
You can expand the SUMPRODUCT formula with multiple conditions by multiplying the arrays or using commas. Use the formula: =SUMPRODUCT(--(LEN(A1:A10)>=5), --(LEN(A1:A10)<=10)). This checks both conditions and only counts the cells that satisfy both.




