## Excel formula: Count cells equal to either x or y

If you want to count cells as long as that meet at least one of given conditions (OR logic) in Excel, i.e. count cells equal to either x or y, you can use several COUNTIF formulas or combine the COUNTIF formula and SUM formula to handle this job.

### Count cells equal to x or y by the COUNTIF function

Generic formula:

 COUNTIF(range,value1)+ COUNTIF(range,value2)+…

Arguments

 Range: Required, the cells you want to count that match to criteria from. Value1, value2: Required, the criteria that the cells need to match to while counting.

Example:

Count the number of cells which are equal to “James Band” or “Steven White” in a name list of cells. Using below formulas

 =COUNTIF(B3:B8,E2)+COUNTIF(B3:B8,E3)

Or

 =COUNTIF(B3:B8,"James Band")+COUNTIF(B3:B8,"Steven White")

In above formulas, the B3:B8 is the range of cells that you want to count cells from, “James Band” and “Steven White” are the criteria you want the cells equal to.

The press Enter key to get the counted result: 4 (Cells equal to James Band or Steven White)

### Count cells equal to x or y by the COUNTIF function and the SUM function together

Also, you can combine the COUNTIF and the SUM functions to count cells equal to x or y.

Generic formula:

 SUM(COUNTIF(range,{criteria1,criteria2,criteria3…}))

Arguments

 Range: Required, the cells you want to count that match to criteria from. Criteria1, criteria2: Required, the criteria that the cells need to match to while counting.

Example:

Count the cells that are equal to Milk, Cookie or Juice in the Food list. Using this formula:

The press Enter key to get the counted result.

### Count cells equal to x or y by the COUNTIF function and the SUMPRODUCT function together

If you want the formula is shorter, you can try to use the COUNTIF function and the SUMPRODUCT function together.

Generic formula:

 SUMPRODUCT(COUNTIF(range,things))

Arguments

 Range: Required, the cells you want to count that match to criteria from. Things: Required, the name of a range that including all criteria you count cells based on.

Example:

Count the cells that equal to one value of 12, 11, or 10 from the Record list. Before you are using the formula, you need to define the criteria cells as a named range. Select the cells contains the criteria, then type a name into the Name box, then press Enter key. See screenshot:

Then using this formula:

 =SUMPRODUCT(COUNTIF(B3:B8,things))

In the formula, B3:B8 is the range that you want to count cells from, things is the defined named range containing all criteria cells.

The press Enter key to get the counted result as below screenshot shown:

### Remarks

• Above formulas count cells without case sensitive.
• If the criteria is a number value, directly type it without double quotation marks, such as COUNTIF(B1:B5,1)+COUNTIF(B1:B5,0), or =SUM(COUNTIF(B1:B5,{1,2,0})).

### 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.