XLOOKUP in Excel can perform partial matches using wildcards (like * or ?) to find text that contains, starts with, or ends with a specified pattern. This is especially useful when search criteria are incomplete or inconsistent (e.g., looking up 'John*' to find 'John Smith' or 'Johnny Doe'). To use wildcards with XLOOKUP, you must set the match_mode argument to 2 (wildcard match) and ensure the lookup_value includes the wildcard characters. Note: Wildcard matching only works for text-based lookups and requires Excel 365 or Excel 2021+.

What You'll Need

  • Microsoft Excel 365 or Excel 2021 (or later)
  • A dataset with text values in the lookup column
  • The XLOOKUP function syntax knowledge (optional but helpful)

Step-by-Step

  1. Open your Excel workbook and ensure the data you want to search is clean and properly formatted. The lookup column must contain text values (e.g., names, product codes, addresses). Remove leading/trailing spaces using =TRIM() if needed.
  2. Decide on the wildcard pattern you want to use:
    • * matches any sequence of characters (e.g., 'A*' finds 'Apple', 'Apricot', 'A123')
    • ? matches any single character (e.g., 'A?ple' finds 'Apple' or 'Aople' but not 'Apricot')
    • ~* or ~? escapes the wildcard meaning if you need to search for literal * or ? characters (e.g., '10~*oz' finds '10*oz')
  3. Enter your XLOOKUP formula in the target cell. The syntax is:
    =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
  4. Set the lookup_value to include your wildcard pattern. For example, if searching for product names starting with 'Laptop' and the search term is in cell B2, use "Laptop*" or B2 & "*" if B2 contains the base term.
  5. Set the match_mode argument to 2. This tells XLOOKUP to use wildcard matching. Do not use 0 (exact match) or 1/-1 (next largest/smallest), as those do not support wildcards.
  6. Complete the formula with the lookup_array (your text column) and return_array (the column with data to retrieve). For example:
    =XLOOKUP("Laptop*", A2:A100, C2:C100, "Not found", 2)
  7. Press Enter. Excel returns the first match it finds. If multiple rows match, only the first is returned—XLOOKUP does not return arrays of multiple matches by default.
  8. To make the search case-insensitive (as XLOOKUP always is), no extra step is needed—wildcard matching is inherently case-insensitive.

Common Mistakes

  • Using match_mode 0 (exact match) with wildcards—this ignores the wildcard characters and looks for a literal string like "Laptop*".
  • Forgetting to include the wildcard in lookup_value (e.g., typing just "Laptop" instead of "Laptop*").
  • Applying wildcards to numeric or date lookups—XLOOKUP wildcards only work with text. If your lookup column contains numbers stored as text, convert them with =TEXT() or =VALUE() first.
  • Using wildcards in the return_array—XLOOKUP only applies wildcards to the lookup, not the result.
  • Assuming multiple matches return all results—XLOOKUP returns only the first match. Use FILTER() for multiple results.

Tips

  • Combine wildcard patterns with TRIM and UPPER/LOWER to normalize text:
    =XLOOKUP("*" & TRIM(UPPER(B2)) & "*", UPPER(A2:A100), C2:C100, "Not found", 2)
  • Use a helper column with consistent formatting (e.g., all uppercase) to improve matching reliability.
  • Escape special characters (like * or ?) in user input using SUBSTITUTE:
    =SUBSTITUTE(B2,"*","~*") & "*" before concatenating into the lookup_value.
  • For fuzzy matching (e.g., typos), wildcards alone won't help—consider Power Query or VBA for advanced text matching.
  • Test your wildcard pattern in a smaller dataset first using COUNTIF to verify it matches as expected:
    =COUNTIF(A2:A100, "Laptop*")

Troubleshooting

If your XLOOKUP with wildcards returns #N/A or unexpected results, follow these checks:

  1. Verify Excel version: Wildcards in XLOOKUP require Excel 365 or Excel 2021+. Check File > Account > About Excel to confirm. Older versions (e.g., Excel 2019) do not support this feature.
  2. Confirm match_mode is 2: Double-check the fifth argument. A typo like 20 or "2" (as text) will cause errors.
  3. Check for hidden characters: Use =CODE(LEFT(A2)) to detect non-printing characters. Clean data with =TRIM(SUBSTITUTE(A2,CHAR(160)," ")).
  4. Ensure lookup_array is text: If A2 contains 123 (a number), "123*" won’t match. Convert with =TEXT(A2,"0") or format the column as Text before entry.
  5. Test the lookup_value logic: In a blank cell, type =ISNUMBER(SEARCH("Laptop",A2)) for your first row. If it returns FALSE, your wildcard pattern may not align with the data.
  6. Check for #VALUE! errors: This often means the lookup_value is not text. Wrap it in =TEXT() or concatenate with an empty string: lookup_value & "".
  7. Confirm no extra spaces in the search term: If B2 has trailing spaces, "Laptop " may fail. Use TRIM(B2) & "".

Frequently Asked Questions

Can I use wildcards with XLOOKUP for numbers?

No—wildcards only work with text. Numbers stored as numbers won’t match patterns like "123*". Convert numbers to text first using =TEXT() or format the column as Text.

Does XLOOKUP with wildcards work across different worksheets?

Yes. Reference the lookup_array and return_array from other sheets, e.g., =XLOOKUP("John*", Sheet2!A:A, Sheet2!B:B, "Not found", 2).

How do I find an exact match that includes a literal asterisk?

Escape the asterisk with a tilde: =XLOOKUP("10~*oz", A2:A100, C2:C100, "Not found", 2) will match "10*oz" exactly.

Why does my formula return #NAME?

This occurs if Excel doesn’t recognize XLOOKUP—likely because you’re using Excel 2019 or earlier. Upgrade to Excel 365 or Excel 2021+, or use VLOOKUP with ~* escaping and match_type 0 (but VLOOKUP doesn’t support wildcards natively).

Can I use wildcards to match partial dates?

No—dates in Excel are stored as serial numbers. Wildcards only apply to text. Convert dates to text first (e.g., =TEXT(A2,"yyyy-mm")) if you need partial date matching.

Does XLOOKUP return all matching rows with wildcards?

No—XLOOKUP always returns only the first match. To get all matches, use the FILTER function: =FILTER(C2:C100, ISNUMBER(SEARCH("Laptop*", A2:A100))) (Excel 365 only).