Test if Value Exists in a Range in Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on February 6, 2023
Download Example Workbook

Download the example workbook

This tutorial demonstrates how to use the COUNTIF function to determine if a value exists in a range.

Test if Value Exists in a Range main Function

 

COUNTIF Value Exists in a Range

To test if a value exists in a range, we can use the COUNTIF Function:

=COUNTIF(Range, Criteria)>0

The COUNTIF function counts the number of times a condition is met. We can use the COUNTIF function to count the number of times a value appears in a range. If COUNTIF returns greater than 0, that means that value exists.

=COUNTIF($E$3:$E$9,B3)

PIC 01

By attaching “>0” to the end of the COUNTIF Function, we test if the function returns >0. If so, the formula returns TRUE (the value exists).

=COUNTIF($E$3:$E$9,B3)>0

PIC 02

 

You can see above that the formula results in a TRUE statement for the name “Patrick Mitchell. On the other hand, the name “Georgia Smith” and “Patrick Svensen” does not exist in the range $B$2:$B$31.

You can wrap this formula around an IF Function to output a specific result. For example, if we want to add a “Does not exist” text for names that are not in the list, we can use the following formula:

=IF(COUNTIF($B$2:$B$31, Name)>0, “Exists”, “Does Not Exist”)

count if value exists in range if function

COUNTIF Value Exists in a Range Google Sheets

We use the same formula structure in Google Sheets:

=IF(COUNTIF(Range, Criteria)>0, “Exists”, “Does Not Exist”)

count if value exists in range google sheets

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