XLOOKUP supports wildcards in its lookup value when you set the match mode to 2 (wildcard character match). To do a wildcard lookup, write your formula with the lookup value containing * (any number of characters) or ? (exactly one character), and set the fifth argument of XLOOKUP to 2. For example, =XLOOKUP("*widget*",A2:A100,B2:B100,"Not found",2) returns the first value in B whose matching cell in A contains "widget". This is the shortest working setup; the rest of this guide covers the exact syntax, the order of arguments, and the traps that make wildcard lookups return the wrong row.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, or Excel 2024. XLOOKUP is not available in Excel 2019 or earlier, and it is not available in Excel for the web in older tenants; if your version lacks it, use INDEX and MATCH with wildcards instead.
  • A lookup range and a return range of the same height (or the same width, if you are looking across columns).
  • Your data arranged so the column you search is the one that contains the text you want to match partially.

Step-by-Step

  1. Decide what pattern you need. Use * to stand for any run of characters and ? for exactly one character. "Acme*" matches anything starting with Acme; "*corp*" matches anything containing corp; "A?me" matches Acme, Abme, and so on. Wildcards only work on text values, not on numbers or dates.
  2. Click the cell where the result should appear and type =XLOOKUP(.
  3. Enter the lookup value with the wildcard inside quotes, for example "*widget*". If the pattern lives in another cell, reference that cell instead, such as D2, and make sure D2 itself contains the asterisks.
  4. Type a comma, then select the lookup array — the single row or column you want to search, for example A2:A100. Do not include the header row.
  5. Type a comma, then select the return array — the matching row or column of values to bring back, for example B2:B100. It must be the same size as the lookup array.
  6. Type a comma, then an optional if_not_found value in quotes, such as "Not found". This is the third argument and is optional but strongly recommended.
  7. Type a comma, then the match mode. For wildcards this must be 2. The full argument order is: lookup_value, lookup_array, return_array, if_not_found, match_mode, search_mode.
  8. Close the bracket and press Enter. A working example is =XLOOKUP("*widget*",A2:A100,B2:B100,"Not found",2).
  9. Check the result against the source data. XLOOKUP returns the first match in the lookup array, so if several rows contain the pattern, confirm that the first one is the one you expected.
  10. If you need to search from the bottom up, add the sixth argument as -1: =XLOOKUP("*widget*",A2:A100,B2:B100,"Not found",2,-1). This returns the last match instead of the first.

Menu labels and dialog wording can differ slightly by Excel version, device, and region, but the formula syntax above is the same on Windows, Mac, and iPad.

Common Mistakes

  • Leaving match_mode at 0 or omitting it. With the default exact match, the asterisks are treated as literal characters, so "*widget*" looks for a cell that literally contains asterisks. You must set the fifth argument to 2.
  • Putting the match mode in the wrong position. The fourth argument is if_not_found, not match_mode. Writing =XLOOKUP("*widget*",A2:A100,B2:B100,2) makes Excel return the number 2 as the not-found value, not enable wildcards.
  • Mismatched array sizes. If the lookup array is A2:A100 and the return array is B2:B50, XLOOKUP returns a #VALUE! error.
  • Searching a numeric column. Wildcards do not apply to numbers. Convert the values to text first, or use a different approach.
  • Forgetting that the pattern is case-insensitive. XLOOKUP wildcard matching does not distinguish upper and lower case, so "*Widget*" and "*widget*" behave the same.
  • Expecting all matches. XLOOKUP returns one result. To list every match, use FILTER with a SEARCH or ISNUMBER test instead.

Tips

  • Use ? when you need to match a fixed number of characters, such as part numbers with a consistent length.
  • If your data genuinely contains asterisks or question marks as text, escape them with a tilde: ~* matches a literal asterisk and ~? matches a literal question mark.
  • Keep the if_not_found argument in place so a missing match shows a readable message instead of #N/A.
  • For a partial match that should be case-sensitive, wildcards will not help; use FILTER with EXACT or FIND instead.
  • Test the pattern on a small copy of your data before applying it to a large table, because the first-match rule can hide duplicates.

Troubleshooting

If the formula returns #N/A, first confirm the match mode is 2 and that the pattern really appears in the lookup column. Check for leading or trailing spaces in the source cells, since "widget " will not match "*widget*" in the way you expect. If you get #VALUE!, compare the sizes of the lookup and return arrays. If the formula returns the wrong row, remember that XLOOKUP stops at the first match — add -1 as the sixth argument to search from the bottom, or switch to FILTER to see all matches. If the function name is not recognised at all, your Excel version does not include XLOOKUP, and you should use INDEX and MATCH with match_type 0 plus wildcards in the lookup value instead.

Frequently Asked Questions

Does XLOOKUP support wildcards by default?

No. You must set the match_mode argument to 2. Without it, asterisks and question marks are treated as ordinary characters.

Can I use a wildcard pattern stored in a cell?

Yes. Put the pattern, including the asterisks, in a cell such as D2 and reference it as the lookup value: =XLOOKUP(D2,A2:A100,B2:B100,"Not found",2).

Why does my wildcard XLOOKUP return #N/A when I can see the text?

The most common causes are a missing match_mode of 2, hidden spaces in the source data, or the value being stored as a number rather than text. Trim the source cells and confirm the data type.

Can XLOOKUP return all rows that match a wildcard?

No. XLOOKUP returns a single result. Use the FILTER function with a SEARCH test to return multiple matching rows.

Do wildcards work with XLOOKUP on Excel for Mac?

Yes, the formula syntax and the match_mode argument are the same on Excel for Mac and Windows, provided your version includes XLOOKUP.

What is the difference between * and ? in XLOOKUP?

* matches any number of characters, including none, while ? matches exactly one character. Both work only when match_mode is set to 2.