To count the cells, equal to either X or Y, we can basically use the function of COUNTIF.

To understand the same in a more detailed manner, let’s take an example:

Count cells equal to either X or Y

As you can see in the image above, we have taken Item ID, Item code as well as Colour.

Now let’s say that we want to count the total no. silver and red items in our data array.

Previously:- How to know the number of the first column in the range?

To do the same, let’s input the formula:

Count cells equal to either X or Y

The formula for the same is =COUNTIF(

The following formula requires range as well as criteria.

Count cells equal to either X or Y

The range is the data from which we need to collect our findings.

Count cells equal to either X or Y

Criteria is the specific category you are looking for. In the above example, we need the total no. of silver as well as red items so we will jot down silver with the help of quotation marks (just like in the image).

Count cells equal to either X or Y

Now as we are aware of the fact that we need to count both silver as well as red so we will again use the formula of countif right after the addition sign. 

Count cells equal to either X or Y

After jotting down the formula, we will select the range again.

Count cells equal to either X or Y

Then comes the criteria.

Count cells equal to either X or Y

As our need is silver plus red items so this time our criteria will be- “Red”.

Count cells equal to either X or Y

After closing the bracket and pressing enter, we have our answer on our screens, i.e. 8.

Count cells equal to either X or Y

Next category is No. of Gold and Rosegold items, so we will use the same function again with different criteria which becomes:

=COUNTIF(B2:D14,”Gold”)+COUNTIF(B2:D14,”Rosegold”)

Count cells equal to either X or Y

The answer is 5. 

So, basically there are in total 8 items of Silver and Red in the data array, and 5 items of Gold and Rosegold.

Count cells equal to either X or Y

It’s easy, isn’t it?