Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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.
doc count equal to either x or y 1

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)
doc count equal to either x or y 2

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:

=SUM(COUNTIF(B3:B8,{"Milk","Cookie","Juice"}))

The press Enter key to get the counted result.
doc count equal to either x or y 3

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:
doc count equal to either x or y 4

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:
doc count equal to either x or y 5

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})).

Sample File

doc sampleClick to download sample file


Relative Formulas


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300 Advanced Features Help You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.

Screen Shot of Excel (with Office Tab installed)

Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Office Tab Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.