Software & OS

Excel Check If Value Is in List: 5 Formulas That Work

To check if a value is in a list in Excel, use =COUNTIF($D$2:$D$6,A2)>0, which returns TRUE when the value in A2 appears anywhere in D2:D6. Wrap it in IF to get a text answer: =IF(COUNTIF($D$2:$D$6,A2)>0,"Yes","No").

The examples below use this layout: the values to check are in A2:A6, and the list to check against is in D2:D6. Change the references to fit your sheet. The dollar signs in $D$2:$D$6 lock the list, so the formula still points at it when you fill it down column B.

Which formula should you use?

GoalFormulaCase sensitive
TRUE/FALSE or Yes/No=COUNTIF($D$2:$D$6,A2)>0No
Same, using MATCH=ISNUMBER(MATCH(A2,$D$2:$D$6,0))No
Return the matching item, or a message=XLOOKUP(A2,$D$2:$D$6,$D$2:$D$6,"Not found")No
Exact case match=SUMPRODUCT(--EXACT(A2,$D$2:$D$6))>0Yes
Partial match (contains)=COUNTIF($D$2:$D$6,"*"&A2&"*")>0No

Check if a value is in a list with COUNTIF

This is the shortest option and works in every Excel version that has COUNTIF.

=COUNTIF($D$2:$D$6,A2)>0

COUNTIF(range, criteria) counts the cells in the range that match the criteria. If the value appears at least once, the count is 1 or more, and the comparison >0 gives TRUE. If it never appears, the count is 0 and you get FALSE.

For a readable label, add IF:

=IF(COUNTIF($D$2:$D$6,A2)>0,"Yes","No")

Example output, with the list D2:D6 containing apples, pears, plums, figs and limes:

A (value)B (formula result)
pearsYes
grapesNo
FIGSYes

Notice that "FIGS" matched "figs". COUNTIF is not case sensitive, per Microsoft's documentation.

COUNTIF treats * and ? as wildcards

In the criteria, ? matches any single character and * matches any run of characters. If the value you are checking can contain those characters, put a tilde in front of them to search for the literal character. A value such as file? in A2 would otherwise match "file1" and "filex" as well. This is also why COUNTIF can do partial matching, covered below.

The 255-character limit

Microsoft states that COUNTIF returns incorrect results when you use it to match strings longer than 255 characters. For long strings such as URLs or sentences, use the MATCH formula below instead, or split the string with & as Microsoft's page shows: =COUNTIF(A2:A5,"long string"&"another long string").

Check with MATCH and ISNUMBER

=ISNUMBER(MATCH(A2,$D$2:$D$6,0))

MATCH(lookup_value, lookup_array, [match_type]) returns the position of the first match in the list, so MATCH("pears",$D$2:$D$6,0) returns 2. When nothing matches, it returns the #N/A error. ISNUMBER returns TRUE for a number and FALSE for anything else, including an error, so the whole formula gives TRUE when a match exists and FALSE when it does not.

Always pass 0 as the third argument. Microsoft documents that when match_type is omitted it defaults to 1, which finds the largest value less than or equal to the lookup value and needs the list sorted in ascending order. An unsorted list with the default can report a value as missing, or as found at the wrong position.

An equivalent that reads more literally is =NOT(ISNA(MATCH(A2,$D$2:$D$6,0))). ISNA is TRUE only for the #N/A error. The ISNUMBER form is shorter and is the one most people use.

Use MATCH when you need the position as well as the yes/no answer, or when the text is longer than 255 characters. Like COUNTIF, it ignores case, and it only accepts wildcards when match_type is 0 and the lookup value is text.

Check with XLOOKUP and return something useful

=XLOOKUP(A2,$D$2:$D$6,$D$2:$D$6,"Not found")

XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], ...) returns the item from the return array that sits at the same position as the match. The fourth argument is what Excel shows when there is no match. If you leave it out, you get #N/A. Its default match_mode is 0, an exact match, so you do not need to set it.

This formula shines when the list has a second column. If D has product codes and E has prices, =XLOOKUP(A2,$D$2:$D$6,$E$2:$E$6,"Not in list") tells you both that the code exists and what it costs. For the full syntax see how to use XLOOKUP in Excel, and for older workbooks how to use VLOOKUP in Excel.

Availability matters here. Microsoft's page lists XLOOKUP for Excel for Microsoft 365, Excel 2021 and Excel 2024, but the same page is inconsistent about Excel 2016 and 2019: its applies-to list names them, while a note says XLOOKUP is not available in those versions. If you share the file with people on older versions, COUNTIF or MATCH is the safer choice.

Check if a value is in a list, case sensitive

COUNTIF, MATCH and XLOOKUP all treat "Apples" and "apples" as the same. To tell them apart, use EXACT, which Microsoft documents as case sensitive:

=SUMPRODUCT(--EXACT(A2,$D$2:$D$6))>0

EXACT(text1, text2) compares the value in A2 against every cell in the list and returns an array of TRUE and FALSE values. The double minus -- turns those into 1 and 0, and SUMPRODUCT adds them up. Microsoft's examples show SUMPRODUCT evaluating array expressions directly, so you do not need a special array-entry step. If the total is above 0, at least one cell matched exactly.

Spaces count as characters in EXACT: "word" and "w ord" are different. Font and other formatting are ignored.

Check if a cell contains part of a list value

To test whether the list contains something that includes your text, add wildcards around the value:

=COUNTIF($D$2:$D$6,"*"&A2&"*")>0

With "pear" in A2 and "pears" in the list, this returns TRUE. It matches anywhere inside a list entry. The reverse case, where a long cell in A contains any of the short words in the list, needs a different formula and is outside what the COUNTIF wildcards can do.

Why a value that is in the list shows as missing

  • Numbers stored as text. A number typed in quotation marks counts as text, not a number; Microsoft's documentation of the IS functions gives ISNUMBER("19") returning FALSE. A cell can look like a number and still be text. Check with =ISNUMBER(A2) on both the value and the list.
  • Stray spaces. "pears " with a trailing space is not "pears". =LEN(A2) shows the real length. =TRIM(A2) removes extra spaces.
  • Wildcard characters in the value. A * or ? in your data acts as a wildcard in COUNTIF.
  • Unlocked references. If you fill the formula down without the $ signs, the list range shifts one row per row and drops entries. Use $D$2:$D$6, not D2:D6.
  • A missing third argument in MATCH. See above: always write ,0).

Check a list on another sheet

Put the sheet name before the range with an exclamation mark:

=IF(COUNTIF(Lists!$A$2:$A$100,A2)>0,"Yes","No")

If the sheet name has spaces, quote it: 'Price List'!$A$2:$A$100.

Frequently asked questions

How do I check if a value is in a list in Excel and return Yes or No?
Wrap COUNTIF in IF: =IF(COUNTIF($D$2:$D$6,A2)>0,"Yes","No"). COUNTIF counts how many cells in the list equal the value, so any count above 0 means the value is in the list. Replace $D$2:$D$6 with your list and A2 with the cell you are checking.
Is COUNTIF case sensitive?
No. Microsoft documents COUNTIF as not case sensitive, so "apples" and "APPLES" count as the same text. MATCH and XLOOKUP also ignore case for text. For a case-sensitive check, use EXACT inside SUMPRODUCT: =SUMPRODUCT(--EXACT(A2,$D$2:$D$6))>0.
Why does COUNTIF say a value is missing when it is in the list?
Common causes are numbers stored as text (the cell shows a number but is left-aligned or has a green triangle), extra spaces before or after the text, or a lookup string longer than 255 characters, which Microsoft says COUNTIF can mishandle. Wildcard characters such as * and ? in the value also change the match.
How do I check a value against a list on another sheet?
Put the sheet name in the range reference, for example =IF(COUNTIF(Lists!$A$2:$A$100,A2)>0,"Yes","No"). If the sheet name contains spaces, wrap it in single quotes: 'Price List'!$A$2:$A$100.

Sources