Yes, you can count cells with text within a subtotal group using the SUMPRODUCT and ISTEXT functions together. This approach ensures that only text entries are counted, ignoring numbers, errors, and blanks, within the specific filtered range. The standard SUBTOTAL function cannot distinguish between data types like numbers and text, so you must combine SUMPRODUCT with ISTEXT to achieve the correct count for text-only cells.

What You'll Need

  • A computer with Microsoft Excel installed (Excel 2019, 2021, or Microsoft 365 are recommended for the best compatibility with array formulas).
  • A dataset containing text values, numbers, and blanks, ideally organized in a table or list format.
  • Basic familiarity with Excel functions, specifically SUMPRODUCT, ISTEXT, and SUBTOTAL.

Step-by-Step

  1. Identify your data range. Determine the specific range of cells that contains the data you want to analyze. For this guide, assume your data is in the range A1:A100. It is highly recommended to use a structured Table (Insert > Table) as your data source, as this makes range references more robust and easier to manage.
  2. Locate the cell for your result. Click on the cell where you want the final count of text cells to appear. This can be anywhere on your worksheet, but placing it near your data (for example, in cell B1 or B2) is usually convenient.
  3. Enter the formula. Type the following formula into the selected cell and press Enter:
    =SUMPRODUCT((SUBTOTAL(103, INDIRECT("R["&ROW(A1:A100)-ROW(A1)&":C["&COLUMN(A1:A100)-COLUMN(A1)&"]"))) * (ISTEXT(A1:A100)))
    This formula is an array formula. It checks every cell in the range A1:A100 to see if it contains text. If it does, and if that cell is currently visible (i.e., not hidden by a filter), the function adds 1 to the total count.
  4. Understand the sub-function 103. The number 103 inside the SUBTOTAL function is the code for the COUNTVISIBLE function. This is crucial because it ensures the formula only counts text cells that are currently visible in the list. If you simply used COUNT (102), it would count text cells even if they were hidden, which is usually not the desired behavior for subtotal analysis.
  5. Verify the result. Check the cell containing the formula. It should display the number of text entries in your specified range. You can test this by applying a filter to your data and filtering out rows containing numbers. The count in your formula cell should decrease accordingly, confirming that it is correctly tracking visible text cells.
  6. Alternative: Count Text Cells in a Table. If you have created a Table (Insert > Table) from your data, you can use a simpler, more readable formula that automatically adjusts to the table's size. Select the cell where you want the count to appear and type:
    =SUMPRODUCT(SUBTOTAL(103, OFFSET(TableName[ColumnName], 0, 0, ROW(TableName[ColumnName])-ROW(TableName[#Headers]), 1))) * (ISTEXT(TableName[ColumnName]))
    Replace "TableName" with your actual table name and "ColumnName" with the name of the column you want to analyze. This method is more dynamic because it uses the table's structure references instead of fixed cell ranges like A1:A100.

Common Mistakes

A common mistake is using the SUM function instead of SUMPRODUCT. The SUM function simply adds up the values returned by the ISTEXT function. However, ISTEXT returns TRUE (which Excel treats as 1) or FALSE (which Excel treats as 0). The SUM function can sometimes ignore certain types of data or return a #VALUE! error if the range contains non-numeric data, whereas SUMPRODUCT is specifically designed to multiply and sum arrays of numbers.

Another error is forgetting to use the INDIRECT function within the SUBTOTAL. Without it, the formula will fail because SUBTOTAL expects a single range reference, not a dynamically calculated range based on the current row and column. The INDIRECT function is the key to making the formula work correctly for any cell in the grid.

Tips

For better performance with very large datasets, consider using a helper column. Create a new column next to your data and enter a simple formula like =ISTEXT(A2) in the first cell. Then, drag this formula down for all rows. Once done, you can use the much simpler and faster formula: =SUBTOTAL(103, HelperColumn). This approach avoids the complexity and potential performance hit of using array formulas with INDIRECT and SUBTOTAL.

Always ensure your data does not contain hidden text characters, such as non-breaking spaces or line breaks. Sometimes what looks like a blank cell is actually a space character. ISTEXT will correctly identify a space as text. If you want to ignore spaces, you can modify the formula to include the TRIM function: =SUMPRODUCT((SUBTOTAL(103, INDIRECT("R["&ROW(A1:A100)-ROW(A1)&":C["&COLUMN(A1:A100)-COLUMN(A1)&"]"))) * (ISTEXT(TRIM(A1:A100))))

Troubleshooting

If your formula returns a #REF! error, check the range references in the INDIRECT function. This error typically occurs if the referenced row or column numbers are outside the valid range of your worksheet. Double-check that the range A1:A100 is correct for your data.

If your formula returns a count that is too high, it is possible that the SUBTOTAL function is not correctly identifying visible cells. This can happen if the data is grouped (using the Outline feature) rather than filtered. The SUBTOTAL function with code 103 only counts visible cells when using standard AutoFilters. If you are using grouping, you may need to use a different method or ensure you are filtering, not grouping.

If your formula returns a #VALUE! error, it is most likely because the range contains a mixture of data types that are incompatible with the calculation. Ensure that the range you are analyzing is clean and does not contain errors or non-textual data that cannot be interpreted by the ISTEXT function.

Frequently Asked Questions

Why does my count not update when I filter?

If your formula is not updating when you apply a filter, ensure that you are using the SUBTOTAL function with the correct code (103). Code 103 is specifically for COUNTVISIBLE. Other codes, like 109 or 110, are for SUMVISIBLE and AVERAGEVISIBLE, respectively, and can lead to incorrect results if not used correctly. Additionally, check that your data is actually filtered and not just hidden by manual row manipulation.

Can I count text cells in multiple columns at once?

Yes, you can count text cells across multiple columns by expanding the range in the ISTEXT function. For example, to count text cells in columns A, B, and C, you would use ISTEXT(A1:C100). The formula will then sum the results for all three columns within the specified range.

What is the difference between ISTEXT and ISNUMBER?

ISTEXT checks if a cell contains text, while ISNUMBER checks if a cell contains a numeric value. They are opposite functions. You can use both together in a formula to identify cells that contain neither text nor numbers (i.e., blanks or errors). For example, =SUMPRODUCT((SUBTOTAL(103, INDIRECT("R["&ROW(A1:A100)-ROW(A1)&":C["&COLUMN(A1:A100)-COLUMN(A1)&"]"))) * (ISTEXT(A1:A100)) + (ISNUMBER(A1:A100))) will count both text and number cells.

Does this work in Excel for the web?

Yes, this formula works in Excel for the web, but with some limitations. The INDIRECT function is not supported in Excel for the web. You will need to use a different approach, such as the helper column method mentioned in the Tips section, or use a simpler formula that does not rely on INDIRECT.

How do I count cells with text that are not filtered out?

If you want to count text cells regardless of whether they are hidden by a filter, you can simply remove the SUBTOTAL function from the formula. The resulting formula would be =SUMPRODUCT(ISTEXT(A1:A100)). This will count all text cells in the specified range, including those that are hidden.