Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

VLOOKUP Contains Text: How to Use Wildcards in Excel

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To perform a VLOOKUP that finds a cell containing specific text rather than an exact match, you must use wildcards—specifically the asterisk (*) symbol—within your lookup value. By wrapping your search term in asterisks (e.g., "*text*"), Excel will return the first record that contains those characters anywhere within the cell. This is essential for searching databases where entries might have inconsistent naming, such as searching for "Apple" in a list that contains "Apple Inc." or "Red Apple Orchard".

What You'll Need

  • Microsoft Excel (any modern version) or Google Sheets.
  • A data table where the lookup column contains the text strings you are searching for.
  • A search term (the partial text you want to find).
  • Basic knowledge of the VLOOKUP formula structure: =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]).

Step-by-Step

  1. Identify Your Data Range: Locate the table containing the information you want to retrieve. Ensure that the column containing the text you are searching for is the leftmost column of your selected range. VLOOKUP cannot search to the left of the lookup column.
  2. Set Up Your Search Cell: For maximum flexibility, type the partial text you are looking for into a specific cell (for example, cell E2) rather than typing it directly into the formula. This allows you to change your search term without editing the formula every time.
  3. Construct the Wildcard Lookup Value: Since VLOOKUP normally looks for an exact match, you need to tell Excel to ignore any characters appearing before or after your search term. You do this by concatenating the asterisk wildcard with your cell reference. In your formula, the lookup value should look like this: "*"&E2&"*". The ampersand (&) joins the asterisks to the value in cell E2.
  4. Define the Table Array: Select the range of cells that contains both the lookup column and the data you want to return. For example, if your data is in columns A through C, your range would be A2:C100. It is highly recommended to use absolute references (e.g., $A$2:$C$100) so that the range does not shift if you copy the formula down to other cells.
  5. Specify the Column Index Number: Count the columns in your selected range from left to right. If the information you want to retrieve is in the third column of your range, enter 3.
  6. Set the Range Lookup to FALSE: To ensure Excel looks for the specific text string (even with wildcards) and doesn't return a nearby approximate match, you must set the final argument to FALSE or 0.
  7. Assemble the Final Formula: Combining these elements, your final formula should look like this: =VLOOKUP("*"&E2&"*", $A$2:$C$100, 3, FALSE). Press Enter to execute the search.
  8. Verify the Result: Check that the returned value corresponds to the first entry in your table that contains the text in cell E2. Remember that VLOOKUP only returns the first match it encounters; if multiple cells contain the text, only the first one is retrieved.

Common Mistakes

One of the most frequent errors is forgetting the quotes around the asterisks. In Excel formulas, any text string, including wildcards, must be enclosed in double quotation marks. Writing *&E2&* will result in a #NAME? error because Excel tries to interpret the asterisks as named ranges or mathematical operators rather than text characters.

Another common mistake is using the wrong wildcard. Users sometimes try to use the question mark (?) when they mean the asterisk (*). While the question mark is a valid wildcard, it only represents a single character. The asterisk represents any number of characters (zero or more), which is what is required for a "contains" search. If you use a question mark, the formula will only find matches where exactly one character differs from your search term.

Many users also forget to set the final argument of the VLOOKUP to FALSE. If left as TRUE or omitted, Excel assumes the data is sorted in ascending order and may return an incorrect result or a #N/A error if the exact partial match isn't found in a way that fits the sorting logic. For wildcard searches, FALSE is mandatory.

Lastly, users often forget that VLOOKUP is limited to searching the leftmost column. If the text you are searching for is in Column B, but the data you want to return is in Column A, VLOOKUP will not work. In these cases, you would need to use a combination of INDEX and MATCH or the newer XLOOKUP function.

Tips

To make your search more specific, you can control where the wildcard is placed. If you only want to find cells that start with your text, remove the first asterisk: E2&"*". If you only want to find cells that end with your text, remove the second asterisk: "*"&E2. This is incredibly useful for searching for specific prefixes or suffixes in product codes or employee IDs.

If you want your search to be more robust, consider wrapping your VLOOKUP in an IFERROR function. Because a "contains" search can easily fail if a typo is made in the search cell, an IFERROR wrapper prevents the ugly #N/A error from appearing. For example: =IFERROR(VLOOKUP("*"&E2&"*", $A$2:$C$100, 3, FALSE), "No match found").

For those using larger datasets, keep in mind that wildcard searches can be slower than exact matches because Excel has to evaluate more possibilities within each cell. If your workbook becomes sluggish, ensure you are only referencing the necessary range of cells rather than entire columns (like A:C), which can force Excel to check over a million rows.

Troubleshooting

If your formula returns #N/A, first check the search term in your lookup cell. Ensure there are no accidental leading or trailing spaces in the search cell or within the data table itself. A space at the end of "Apple " will not match "Apple" unless the wildcards are correctly placed. You can use the TRIM function to clean your data if spaces are the culprit.

If the formula returns the wrong value, check if there are multiple cells that contain the search text. VLOOKUP always stops at the first match. If you need to find all occurrences or a specific occurrence, VLOOKUP is the wrong tool; you should use the FILTER function instead, which can return multiple rows that meet the "contains" criteria.

If you receive a #VALUE! error, double-check your column index number. If you have selected a range of three columns (A:C) but told VLOOKUP to return the 4th column, it will trigger this error. Ensure the index number is less than or equal to the number of columns in your selected array.

If the formula simply doesn't seem to be finding a match that you can clearly see with your eyes, verify that the data types are consistent. While wildcards work on text, if you are searching for a number that is stored as text, it will work, but if you are searching for a number stored as a number using text wildcards, it may fail. Ensure the lookup column is formatted as Text.

Frequently Asked Questions

Does VLOOKUP contains text work with case sensitivity?

No, VLOOKUP is not case-sensitive. Searching for "*APPLE*" will return matches for "apple", "Apple", and "APPLE". If you need a case-sensitive search, you must use a combination of the FIND function and INDEX/MATCH.

Can I use multiple wildcards in one VLOOKUP?

Yes, you can use multiple asterisks within a single string. For example, if you search for "*North*Sales*", Excel will find any cell that contains the word "North" followed by the word "Sales" anywhere later in the string, regardless of what is between them.

Is there a better alternative to VLOOKUP for partial matches?

Yes, the XLOOKUP function is generally superior. It allows you to specify the match mode explicitly. By setting the match_mode argument to 2, XLOOKUP enables wildcard matching without needing to concatenate asterisks inside the lookup value as strictly as VLOOKUP does, and it can search in any direction.

Why is my wildcard VLOOKUP returning a blank cell?

This usually happens when the formula successfully finds a match, but the cell in the return column for that specific row is empty. VLOOKUP returns a 0 or a blank if the target cell has no content, even if the lookup column matched perfectly.

Can I use this method to search for a specific character like a question mark?

Because the question mark and asterisk are reserved as wildcards, searching for them literally requires a "tilde" (~) before the character. To search for a cell containing a literal question mark, your lookup value would need to be "*~?*".