How to Count Matching Text Once Per Row in Excel
Question details
The user needs to count the number of rows where a specific text term appears at least once across multiple columns, ignoring multiple occurrences within the same row.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Analyzing text data across multiple columns and needing to count unique row occurrences of a specific term.
- Observed behavior
- The user wants to ensure that multiple instances of a term in the same row are only counted as a single occurrence for that entire row.
Ensure your data range is contiguous and note the exact column references, as the array formula requires matching dimensions for accurate matrix multiplication.
Use SUMPRODUCT, SEARCH, and MMULT Functions
This advanced array formula checks each row for the target text and counts the row only once, even if the text appears in multiple columns.
This method uses ISNUMBER and SEARCH to find the text, MMULT to sum the occurrences per row, and SUMPRODUCT to tally the rows that meet the criteria.
Click on the cell where you want the final count result to appear.
Enter the formula using SUMPRODUCT and MMULT. For example: =SUMPRODUCT((Range1=Condition1)*(MMULT(--(ISNUMBER(SEARCH("your_term", Text_Range))), TRANSPOSE(COLUMN(Text_Range)^0))>0)).
Replace 'your_term' with the text you are looking for (e.g., "pneumonitis") and update the ranges (like '$AI$2:$AM$1423') to match your actual data columns.
If you are using an older version of Excel (prior to Microsoft 365), press Ctrl+Shift+Enter to confirm it as an array formula. Modern versions only require pressing Enter.

Use Helper Columns (Alternative Method)
If complex array formulas are too slow or difficult to maintain, you can use a helper column to flag rows containing the text.
Count Text and Analyze Data Efficiently with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array formulas like SUMPRODUCT and MMULT, making it easy to count specific text strings across rows. It offers a smooth, lightweight experience for all your data analysis needs.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your .xlsx file containing the text data.
- 2. Apply the COUNTIF helper column or SUMPRODUCT formula: Use the exact same formula logic, as WPS Spreadsheet fully supports Excel's syntax and array capabilities.
- 3. Press Enter to calculate: WPS Spreadsheet automatically processes dynamic arrays in newer versions, instantly calculating your row-specific text counts.

Frequently Asked Questions
Why does my MMULT formula return a #VALUE! error?
This usually happens if the two arrays in the MMULT function do not have compatible dimensions. Ensure the number of columns in your text range exactly matches the number of rows in the array generated by the TRANSPOSE function.
Can I count multiple different terms at once?
Yes, but the formula becomes more complex. You would need to add multiple SEARCH conditions using the '+' operator inside the ISNUMBER function to act as an OR logic gate.
Does this formula differentiate between exact match and partial match?
The SEARCH function used in this formula looks for partial matches and is not case-sensitive. If you need a case-sensitive exact match, replace the SEARCH function with the FIND function.
Do I always need to use Ctrl+Shift+Enter for this formula?
In Microsoft 365, Excel 2021, and modern versions of WPS Spreadsheet, you can simply press Enter. In older versions like Excel 2016 or 2019, you must use Ctrl+Shift+Enter to evaluate it as an array formula.




