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 where you only have first names, and now, you need to check if “Arlene” is there or not.
You can use the following steps:
- First, you need to enter the IF function in cell B1.
- After that, in the first argument (logical test), you need to enter the COUNTIF function there.
- Now, in the COUNTIF function, refer to the range A1:A10.
- Next, in the criteria argument, enter “Glen” and close the parentheses for the COUNTIF Function.
- Additionally, use a greater than sign and enter a zero.
- From here, enter a comma to go to the next argument in the IF, and enter “Yes” in the second argument.
- In the end, enter a comma and enter “No” in the third argument and type the closing parentheses.
The moment you hit enter it returns “Yes”, as you have the value in the range that you have searched for.
How this Formula Works
This formula has two parts.
In the first part, we have COUNTIF, which counts the occurrence of the value in the range.
And 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 which means the value is there in the range IF returns Yes.
And if COUNTIF returns 0, which means the value is not there in the range and it returns No.
Check for a Value in a Range Partially
There count to be a situation where you want to check for partial value from a range. In that case, you need to use wildcard characters (asterisk *).
In the following example, we have the same list of names but here is the full name. But we still need to look for the name “Glen”.
The value you want to search for needs to 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 there before and after the value.
🔙 Excel Formulas \ 📂 sample-file