## Count cells that contain either x or y in a range in Excel

To count cells that contain either one value or another, some Excel users may add two COUNTIF functions together to deal with it, however, this method counts cells with AND logic (contain both x and y) instead of OR logical (contain either x or y). To avoid double counting the criteria, this tutorial is going to show you how to apply a formula based on the SUMPRODUCT function in details to count the number of cells in a specific range that contain either x or y in Excel.

#### How to count cells that contain either x or y in a range in Excel

As the below screenshot shown, there is a data range B3:B9, to count the number of cells in this range that contains either “KTE” or “KTO”, please apply the below formula to get it done.

Generic Formula

=SUMPRODUCT(--((ISNUMBER(FIND("criteria1",rng)) + ISNUMBER(FIND("criteria2",rng)))>0))

Arguments

Rng (required): The range from which you want to count cells that contain either x or y.

Criteria1 (required): One string or character you want to count cells based on.

Criteria2 (required): Another string or character you want to count cells based on.

How to use this formula?

1. Select a blank cell to output the result.

2. Enter the below formula into it and press the Enter key to get the result.

=SUMPRODUCT(--((ISNUMBER(FIND(D3,B3:B9)) + ISNUMBER(FIND(D4,B3:B9)))>0))

How these formulas work?

=SUMPRODUCT(--((ISNUMBER(FIND(D3,B3:B9)) + ISNUMBER(FIND(D4,B3:B9)))>0))

• 1. FIND(D3,B3:B9): The FIND function checks for whether the value “KTE” in D3 existing in the specified range (B3:B9), and returns an array: {1,#VALUE!,#VALUE!,#VALUE!,#VALUE!,1,#VALUE!}.
In this array, the two 1s represent that the first and the second to last cells in the list B3:B9 containing value “KTE”, the #VALUE!s represent the value “KTE” does not find in other cells.
• 2. ISNUMBER{1,#VALUE!, #VALUE!, #VALUE!, #VALUE!,1, #VALUE!}: The ISNUMBER function returns TURE if meeting number in the array, and returns FALSE if meeting errors, and finally returns the new array as {TURE;FALSE;FALSE;FALSE;FALSE;TURE;FALSE}.
• 3. FIND(D4,B3:B9): This FIND function also checks for whether the value “KTO” in D4 existing in the specified range (B3:B9), and returns an array: {#VALUE!,1,#VALUE!,#VALUE!, #VALUE!,#VALUE!,#VALUE!}.
• 4. ISNUMBER{#VALUE!,1,#VALUE!,#VALUE!, #VALUE!,#VALUE!,#VALUE!}: The ISNUMBER function returns TURE if meeting number in the array, and returns FALSE if meeting errors, and finally returns the new array as {FALSE;TURE;FALSE;FALSE;FALSE;FALSE;FALSE}.
• 5. {TURE;FALSE;FALSE;FALSE;FALSE;TURE;FALSE} + {FALSE;TURE;FALSE;FALSE;FALSE;FALSE;FALSE}: Here the two arrays returns the result as {1;1;0;0;0;1;0}.
• 6. {1;1;0;0;0;1;0}>0: Here compares whether each number in the array is greater than 0 and returns the result as {TURE;TRUE;FALSE;FALSE;FALSE;TURE;FALSE}.
• 7. --({TURE;TRUE;FALSE;FALSE;FALSE;TURE;FALSE}): These two minus signs convert “TRUE” into 1 and convert “FALSE” into 0. Here you will get a new array as {1;1;0;0;0;1;0}.
• 8. =SUMPRODUCT({1;1;0;0;0;1;0}): The SUMPRODUCT function sums all number in the array and returns the final result as 3 in this case.

#### Related functions

Excel SUMPRODUCT function
The Excel COUNTBLANK function can be used to multiply two or more columns or arrays together, and then get the sum of products.

Excel ISNUMBER function
The Excel ISNUMBER function returns TRUE when a cell contains a number, and FALSE if not.

Excel FIND function
The Excel FIND function is used to find a string within another string, and returns the starting position of the string inside another one.

#### Related formulas

Count cells that begin or end with specific text

Count Blank/Nonblank Cells
This article explains formulas to count the number of blank and nonblank cells in a range in Excel.

Count cells that contain specific text with case sensitive
This tutorial provides a formula in details to count the number of cells that contains specific text with case sensitive in a range in Excel.

Count how many cells contain errors
This tutorial shows how to count the number of cells that contains errors (any kind of errors, such as #N/A error, #VALUE! error or #DIV/0! error) in a specified range in Excel.

### The Best Office Productivity Tools

#### Kutools for Excel - Helps You To Stand Out From Crowd

 🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions… Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ... Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup... Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List... Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Columns to Select Same & Different Cells ... Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ... Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

#### Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

• One second to switch between dozens of open documents!
• Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
• Increases your productivity by 50% when viewing and editing multiple documents.
• Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.