Check IF a Value Exists in a Range (Formula in Excel)

puneet-gogia-excel-champs

- Written by Puneet

In Excel, to check if a value exists in a range or not, you can use the COUNTIF function with the IF function. With COUNTIF, you can check for the value, and with IF, you can return a result value to show to the user. i.e., Yes or No, Found or Not Found.

Check for a Value in a Range

In the following example, you have a list of names that only includes first names, and now you need to check if “GLEN” is there.

list-of-names

You can use the following steps:

  1. First, you need to enter the IF function in cell B1.
    enter-the-if-function
  2. After that, in the first argument (logical test), you need to enter the COUNTIF function there.
    enter-the-count-if-function
  3. Now, in the COUNTIF function, refer to the range A1:A10.
    refer-to-a-range
  4. Next, in the criteria argument, enter “Glen” and close the parentheses for the COUNTIF Function.
    close-the-prentheses
  5. Additionally, use a greater than sign and enter a zero.
    use-greater-than-sign
  6. From here, enter a comma to go to the next argument in the IF, and enter “Yes” in the second argument.
    next-argument-in-if
  7. In the end, enter a comma and enter “No” in the third argument and type the closing parentheses.
    type-the-closing-prantheses

The moment you hit enter it returns “Yes”, as you have the value in the range that you have searched for.

returns-the-value
=IF(COUNTIF(A1:A10,"Glen")>0,"Yes","No")

Want to learn more? Check out this Free Courses: 50 Excel Formulas to Get Smarter than Your Colleagues

How this Formula Works

This formula has two parts.

if-countif-formula

In the first part, we have COUNTIF, which counts the occurrence of the value in the range. In the second part, you have the IF function that takes the values from the COUNTIF function.

So, if COUNTIF returns any value greater than that, it means the value is in the range IF returns Yes. If COUNTIF returns 0, it means the value is not in the range, and it returns No.

Check for a Value in a Range Partially

There counts to be a situation where you want to check for partial value from a range. In that case, you must use wildcard characters (asterisk *).

In the following example, we have the same list of names, but here is the full name. We still need to look for the name “Glen.”

check-value-in-range-partially

The value you want to search for must be enclosed with an asterisk, which we have used in the above example. This tells Excel to check for the value “Glen” regardless of what is before and after it.

=IF(COUNTIF(C1:C10,"*"&"Glen"&"*")>0,"Yes","No")

Get the Excel File

Download

Get the Excel File

Last Updated: June 19, 2024

3 thoughts on “Check IF a Value Exists in a Range (Formula in Excel)”

  1. Great info, thank you. It is just my excel uses “;” as a separator instead of “,” , so copying the code didn’t worked, I had to write it and autocomplete showed ;

    Reply
  2. You start the problem statement with searching for Arlene, but then move to Glen. Slightly confusing…

    Reply

Leave a Comment