How to Count Excel Rows Containing Any Search Term Without Duplicates
Question details
The user wants to count the number of rows in Excel that contain at least one of several specific search terms, ensuring each matching row is only counted once even if it contains multiple target keywords.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Analyzing text data where rows need to be aggregated based on the presence of multiple keywords (e.g., "blueberries", "caribou", "reindeer") without inflating the count.
- Observed behavior
- Using separate COUNTIF functions results in duplicate counts for rows that contain more than one of the target search terms.
Ensure your target column does not contain hidden characters or trailing spaces, and identify the exact list of search terms you want to find before applying the formula.
Use an Array-Based BYROW Formula
This dynamic array formula tests all terms across the specified range and counts each matching row exactly once, avoiding duplicate counts.
This approach uses the BYROW and LAMBDA functions combined with SEARCH to check each row for multiple terms simultaneously. It is highly effective for modern Excel versions supporting dynamic arrays.
Click on the blank cell where you want the final unique row count to appear.
Type the formula: =SUM(--BYROW(C2:C100,LAMBDA(x,--(SUM(--ISNUMBER(SEARCH({"blueberries","caribou","reindeer","Rangifer"},x)))>0))))
Replace C2:C100 with your actual data range, and update the text strings inside the curly brackets to match your specific search terms.
Press Enter to execute the formula. It will automatically calculate the total number of unique rows containing any of the terms.

Filter and Count Rows Using Power Query
Power Query provides a visual way to filter rows containing specific text strings without complex nested formulas, which is especially useful for larger datasets.
Effortlessly Count and Analyze Data with WPS Spreadsheet
WPS Spreadsheet fully supports advanced dynamic array functions like BYROW and LAMBDA, making it easy to perform complex data counting tasks without duplicate errors.
- 1. Open your data file: Launch WPS Spreadsheet and open your .xlsx or .csv data file.
- 2. Select a cell: Click on any empty cell where you want to display the calculation result.
- 3. Input the dynamic formula: Type or paste the BYROW and SEARCH array formula directly into the formula bar.
- 4. Get the accurate count: Press Enter to instantly process the data and display the accurate count without duplicates.

Frequently Asked Questions
Why does using multiple COUNTIF formulas give me the wrong total?
When you add multiple COUNTIF formulas together (e.g., COUNTIF(A:A, "*apple*") + COUNTIF(A:A, "*banana*")), a row containing both words gets counted twice, leading to an artificially inflated total.
Can I use this formula to count exact word matches only?
The SEARCH function finds substrings, meaning 'car' will match 'caribou'. To find exact whole words, you can add spaces around your search terms in the array (e.g., " car ") or use more advanced regular expression functions.
Is the SEARCH function case-sensitive?
No, the SEARCH function ignores text case. If you need strict case-sensitive matching for your search terms, replace the SEARCH function in the formula with the FIND function.




