Count Cells Equal to one of two Results – Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on February 7, 2023
Download Example Workbook

Download the example workbook

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

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to Excel Formulas List