Today, we want to count how many times we sold apples, pears and oranges. We are going to use a small table to check our results, because with a big­ger table it isn’t going to be easy. We will use the COUNTIF func­tion. This func­tion has got only two argu­ments. The first one is a range, where we will be check­ing our con­di­tions or cri­te­ria. In our case, the cri­te­ri­on is the name of our prod­uct, so we are select­ing the cell with the prod­uct name. Such a func­tion will check each cell in the range, whether it con­tains the name or not.

COUNTIF func­tion — how many times we sell apples

=COUNTIF(B2:B10,F2)

COUNIF function
Fig. 1 COUNTIF function

If a cell con­tains the name, the func­tion will add 1 to the counter. We can see that there are four 1s. 

 Four 1s
Fig. 2 Four 1s

We also have to lock the range by press­ing the F4 key, so that it stays in the same place. Cri­te­ria, how­ev­er, should not be locked because we want them to change while copy­ing the for­mu­la down, i.e. we want a giv­en prod­uct to change.

=COUNTIF($B$2:$B$10,F2)

Locked range
Fig. 3 Locked range

After enter­ing and copy­ing down, we have our results. We can see that apples have been sold four times, pears three times and oranges two times. It will also work with big­ger tables. All we need to do is to write a big­ger range.

=COUNTIF($B$2:$B$10,F2)

Final results
Fig. 4 Final results

https://www.youtube.com/watch?v=krHpltXwMAk