In this tutorial, we will count the number of cells that contain either one result or another result.

countif excel equal to x or y title

Count Cells Equal to with COUNTIF

The COUNTIF function counts the number of times the specified value exists in the range. By adding together the results of two COUNTIF functions we can calculate the number of items that are equal to one of two results.

Using the data set above, let’s say that we want to find the number of times the name “George” and the name “Caitlyn” exists.

=COUNTIF(A2:A10, “George”) + COUNTIF(A2:A10, “Caitlyn”)

countif excel equal to x or y example

We end up with a result of 3. This is because the name “George” exists twice in that range (in cells A4 and A6) and the name “Caitlyn” exists only once (in cell A7).

Please keep in mind that if you can look for as many results as you would like, just remember to add the additional “+” sign.

You can also use wildcards to find partial matches. For example, if you want to count the number of cells that start with G and the number of cells that start with A, we can use the following formula.

=COUNTIF(A2:A10, “G*") + COUNTIF(A2:A10, “A*”)

countif excel equal to x or y example wildcard

This results in 4 because we have two names starting with G (A4 and A6) and two names that start with C (A7 and A11).

Count Cells Equal to X or Y in Google Sheets

The above functions work the same way in Google Sheets as well.

=COUNTIF(A2:A10, “George”) + COUNTIF(A2:A10, “Caitlyn”)

countif excel equal to x or y google sheets 1

=COUNTIF(A2:A10, “G*") + COUNTIF(A2:A10, “A*”)

countif excel equal to x or y google sheets 2