How to Count Cells equal to X or Y in Excel

This post will guide you how to count the number of cells equal to criteria X or Y in a given range cells using a formula in Excel 2013/2016.You can easily to count cells equal to a specific value through COUNTIF function. But if there is an easy way to count cells equal to either one value or another value in a selected range of cells in Excel.

Count Cells equals to Criteria X or Y


Assuming that you want to count cells that contain value “EXCEL”or “word” defined in a selected range(A1:B6).In this case, you can use the COUNTIF function twice to count cells which are equal to X or Y.

Enter the following formula in a blank cell, and press Enter key:

=COUNTIF(A2:A6,”EXCEL”)+COUNTIF(A2:A6,”word”)

count cells equals to x or y1

Note: A2:A6 is the data range that you want to use. And both“EXCEL” and “word” are the text values that you want to count in range A2:A6. You need to change them as you need.

Now Let’s see how this formula works:

The COUNTIF function will count the number of cells in a given range that match supplied criteria. In the above formula, there are two COUNTIF function, and contain two criteria.

One criteria is “EXCEL”, another is “word”. The first COUNTIF function returns the number of count equal to “EXCEL”in A2:A6.

The second COUNTIF function returns the count of cells equal to criteria “word” in the range A2:A6. The formula adds both results returned by these two COUNTIF function and return a final result.

Note: you need to know that the COUNTIF function is not case sensitive. And if you want to count the number of cells in a range with case-sensitive, you need to use EXACT function.

You can also use another array formula to achieve the same result of counting cells equal to either “EXCEL” or “word” in A2:A6. Just using the following formula based on the SUM function and the COUNTIF function:

=SUM(COUNTIF(A2:A6,{“EXCEL”,”word”}))

count cells equals to x or y2

Since two criteria were provided in the COUNTIF function, it will return an array result that containing multiple result. You can press “Fn” + “F9” to display the array result. Like below:

count cells equals to x or y3

count cells equals to x or y4

{3,1}

The SUM function will add this array results and return a final result of 4.

Related Functions

  • Excel COUNTIF function
    The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…
  • Excel EXACT function
    The Excel EXACT function compares if two text strings are the same and returns TRUE if they are the same, Or, it will return FALSE.The syntax of the EXACT function is as below:= EXACT (text1,text2)…
  • Excel SUM function
    The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)…

 

 

Related Posts

6 Best Free Wedding Budget Templates

This post will show you some free wedding budget spreadsheet templates for both google sheets and Microsoft Excel Spreadsheet, as well as some explanations of the features or important function points of these templates. You can then easily make modifications ...

Calculate Cumulative Totals with Excel SUM Function

Today, through a simple example, we will show you how to use one of the most common-used Mathematical functions in excel, the SUM function, to add up the sum. In our daily life, we keep an account of what we ...

Check Dates in chronological order
sort dates in chronological order1

Assume you have a date list that has different date formats, as seen in the accompanying picture. In this instance, Excel's Sort function will fail to sort them appropriately. However, you may convert all various date formats to a particular ...

How to Use 3D SUM Multiple Worksheets
3D sum multiple worksheets1

To sum a range of numbers is straightforward for most Excel users, but do you know how to establish a 3D reference to total the same range of numerous sheets. In this post, I will present the steps for this ...

If Cell Begins with One of Three Supplied Characters
If Cell Begins with One of Three Supplied Characters

If you want to test values to see if they begin with some given specific characters like “x”, ”y”, or “z”, you can create a formula with COUNTIF and SUM functions to return results. EXAMPLE You can see “TRUE” or ...

Average per Week by Formula in Excel
Average per Week 1

We usually apply AVERAGE function or relevant functions to return average directly in Excel worksheet. But in some situations, only applying average relevant functions cannot figure out our problem. Sometimes we can create a formula with functions and mathematical operation ...

How to Sum if Contains an Asterisk
How to Sum if Contains an Asterisk 7

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

How to Sum in Vertical Range
How to Sum in Vertical Range 8

If we want to add numbers based on some conditions in Excel worksheet, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In this article, we will introduce you the method ...

How to Sum in Horizontal Range
How to Sum in Horizontal Range9

To add numbers together we need to apply SUM function. But if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In ...

How to Sum with Criteria and Or Logic in Excel
How to Sum with Criteria and Or Logic in Excel 8

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

Sidebar