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:

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:

The formula for the same is **=COUNTIF(**

The following formula requires range as well as criteria.

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

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

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.

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

Then comes the criteria.

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

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

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”)**

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.

It’s easy, isn’t it?