Formula Errors

How to Count Excel Rows Containing Any Search Term Without Duplicates

Steve KSteve K Oct 21, 2026 868 views

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.

How to Count Excel Rows Containing Multiple Search Terms Without Duplicates
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the target cell

Click on the blank cell where you want the final unique row count to appear.

2
Enter the array formula

Type the formula: =SUM(--BYROW(C2:C100,LAMBDA(x,--(SUM(--ISNUMBER(SEARCH({"blueberries","caribou","reindeer","Rangifer"},x)))>0))))

3
Adjust the parameters

Replace C2:C100 with your actual data range, and update the text strings inside the curly brackets to match your specific search terms.

4
Calculate the result

Press Enter to execute the formula. It will automatically calculate the total number of unique rows containing any of the terms.

Use an Array-Based BYROW Formula
Formula Compatibility: The BYROW and LAMBDA functions require newer versions of Excel or WPS Office. For older versions, alternative array formulas using SUMPRODUCT may be required.
Advanced Data Analysis in WPS

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. 1. Open your data file: Launch WPS Spreadsheet and open your .xlsx or .csv data file.
  2. 2. Select a cell: Click on any empty cell where you want to display the calculation result.
  3. 3. Input the dynamic formula: Type or paste the BYROW and SEARCH array formula directly into the formula bar.
  4. 4. Get the accurate count: Press Enter to instantly process the data and display the accurate count without duplicates.
Fully compatible with Microsoft Excel formulas and .xlsx file formats.Supports dynamic arrays and advanced LAMBDA functions natively.Lightweight, fast, and completely free for everyday data analysis.Familiar ribbon interface ensures a zero learning curve for Office users.
microsoft office alternative - wps office

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.