Excel does not have a standalone function named "LIKE" as you would find in SQL, but you can achieve the exact same result by combining the SEARCH or FIND functions with wildcards or using the COUNTIF function. This allows you to identify cells that contain specific text patterns, such as all words starting with "Smart" or all email addresses ending in ".com".
What You'll Need
- Microsoft Excel (Desktop, Web, or Mobile version)
- A dataset containing text strings you wish to filter or identify
- Basic knowledge of how to enter a formula into a cell
Step-by-Step
Depending on whether you want to flag a row (True/False) or count how many cells match a pattern, use one of the following methods. Note that menu labels and function behavior may vary slightly based on your version of Excel or regional language settings.
Method 1: Using COUNTIF for Simple Pattern Matching
This is the fastest way to check if a cell "looks like" a specific value using wildcards.
- Click on the empty cell where you want the result to appear.
- Type
=COUNTIF(followed by the cell reference you are checking (e.g.,A2). - Enter a comma, then put your search term in quotation marks using wildcards.
- Use an asterisk (
*) to represent any number of characters. - Example:
"*Smart*"finds any cell containing the word "Smart" anywhere. - Example:
"Smart*"finds cells that start with "Smart". - Example:
"*Home"finds cells that end with "Home".
- Use an asterisk (
- Close the parenthesis and press Enter. The formula should look like:
=COUNTIF(A2, "*Smart*"). - If the result is 1, the cell matches the pattern; if 0, it does not.
Method 2: Using SEARCH for a True/False Flag
If you need a result that says "TRUE" or "FALSE" (useful for Conditional Formatting or IF statements), use the SEARCH function.
- Select the cell where you want the indicator.
- Type
=ISNUMBER(SEARCH("text", A2)). Replace "text" with the word you are looking for and A2 with your data cell. - Press Enter.
- SEARCH looks for the text and returns the position number if found.
- ISNUMBER converts that position number into "TRUE" and any error (not found) into "FALSE".
- Drag the fill handle (the small square at the bottom-right of the cell) down to apply the formula to the rest of your column.
Method 3: Using Wildcards in the Filter Menu
If you do not need a formula and just want to see the rows that match a pattern:
- Select the header of the column you want to filter.
- Go to the Data tab and click the Filter button.
- Click the filter arrow that appears in the column header.
- Select Text Filters > Contains... (or "Begins With" / "Ends With").
- Type the text you are looking for in the box and click OK.
Common Mistakes
- Forgetting Quotation Marks: In formulas like COUNTIF, text and wildcards must be enclosed in double quotes (e.g.,
"*text*"). Without them, Excel will return a #NAME? error. - Confusing SEARCH and FIND: The SEARCH function is case-insensitive (it doesn't care if letters are uppercase or lowercase). The FIND function is case-sensitive. Using FIND when you don't need case sensitivity will lead to missed results.
- Overusing Wildcards: Placing an asterisk at both the beginning and end (
"*text*") is the most flexible, but if you only want things that start with a word, remember to remove the first asterisk.
Tips
- Cell Referencing: Instead of typing the text inside the formula, point the formula to another cell. For example:
=COUNTIF(A2, "*" & B1 & "*"). This allows you to change the search term in cell B1 without editing the formula. - The Question Mark Wildcard: While the asterisk (
*) replaces any number of characters, the question mark (?) replaces exactly one single character. This is useful for finding codes with a specific length. - Combining with IF: Wrap your SEARCH formula in an IF statement to create custom labels. Example:
=IF(ISNUMBER(SEARCH("Smart", A2)), "Match", "No Match").
Troubleshooting
If your "LIKE" logic is not returning the expected results, try these steps in order:
- Check for Hidden Spaces: Often, a cell looks like it matches but contains a trailing space (e.g., "Smart "). Use the
=TRIM(A2)function to remove extra spaces from your data. - Verify Data Type: Ensure the column is formatted as "General" or "Text". If the cells are formatted as "Number", text-based wildcards will not work.
- Check for Case Sensitivity: If you are using the FIND function and it is returning #VALUE!, try switching to the SEARCH function to see if the issue is uppercase vs. lowercase letters.
- Refresh Filters: If you used the Filter menu and added new data, the filter does not update automatically. Go to the Data tab and click Reapply.
Frequently Asked Questions
Can I use the LIKE function in Excel VBA?
Yes, in VBA (Excel's programming language), there is an actual Like operator used in If-Then statements to compare strings using wildcards.
Does the asterisk wildcard work in all Excel versions?
Yes, wildcards like the asterisk and question mark are standard features across all modern versions of Excel, including Excel 365, 2021, 2019, and Excel for the Web.
How do I search for a literal asterisk in a cell?
Because the asterisk is a wildcard, you must use a tilde (~) before it. For example, searching for "~*" tells Excel to look for the actual symbol rather than using it as a wildcard.
Is there a way to do a "NOT LIKE" search?
Yes. In a formula, wrap your logic in the NOT function. For example: =NOT(ISNUMBER(SEARCH("text", A2))) will return TRUE if the text is NOT found.
Can I use these methods to find patterns in numbers?
Wildcards only work on text. To use "LIKE" logic on numbers, you must first convert the number to text using the =TEXT(A2, "0") function or by adding an empty string: =A2 & "".