To create an "IF LIKE" formula in Excel, you must combine the IF function with the SEARCH or FIND function, as Excel does not have a built-in "LIKE" operator similar to SQL. The most common formula is =IF(ISNUMBER(SEARCH("text", A1)), "Yes", "No"). This checks if a specific string of text exists anywhere within a cell and returns a value based on whether that text was found.

This technique is essential for categorizing data, flagging specific keywords in long descriptions, or organizing lists where you only have a partial match rather than an exact one. For example, you can use it to find every cell that contains the word "Apple" even if the cell actually says "Green Apple" or "Apple Pie."

What You'll Need

  • Microsoft Excel (any modern version) or Google Sheets.
  • A dataset containing the text strings you wish to analyze.
  • A clear understanding of the "keyword" you are searching for and the "result" you want to see if that keyword is found.

Step-by-Step

  1. Identify your target cell and keyword: Determine which cell contains the text you want to check (e.g., cell A2) and the specific word or phrase you are looking for (e.g., "Urgent").
  2. Start with the SEARCH function: In a new cell, type =SEARCH("Urgent", A2). The SEARCH function looks for the text "Urgent" inside cell A2. If it finds it, it returns the character position (a number). If it doesn't, it returns a #VALUE! error.
  3. Wrap it in ISNUMBER: Because the IF function cannot handle the #VALUE! error directly, you must convert the result into a TRUE or FALSE value. Change your formula to =ISNUMBER(SEARCH("Urgent", A2)). Now, if the text is found, the formula returns TRUE; if not, it returns FALSE.
  4. Add the IF function: Now, wrap the entire statement in an IF function to define your custom outputs. Use the format: =IF(logical_test, value_if_true, value_if_false).
    Example: =IF(ISNUMBER(SEARCH("Urgent", A2)), "High Priority", "Normal").
  5. Apply the formula to your list: Click the small green square (fill handle) at the bottom-right corner of the cell containing your formula and drag it down to apply the "IF LIKE" logic to the rest of your column.
  6. (Optional) Use a cell reference for the keyword: Instead of typing "Urgent" inside the formula, type the keyword in cell B1 and reference it. This allows you to change the search term without editing every formula.
    Example: =IF(ISNUMBER(SEARCH($B$1, A2)), "Match", "No Match"). (Note: The dollar signs $ lock the reference to cell B1).

Common Mistakes

  • Forgetting ISNUMBER: If you use =IF(SEARCH("text", A2), "Yes", "No"), the formula will return a #VALUE! error whenever the text is not found, rather than returning "No".
  • Case Sensitivity Confusion: Using the FIND function instead of SEARCH. FIND is case-sensitive (it treats "Apple" and "apple" as different words), whereas SEARCH is case-insensitive.
  • Incorrect Quote Marks: Forgetting to put the search text in double quotation marks. Excel treats text without quotes as a named range or a function, which will result in a #NAME? error.
  • Absolute vs. Relative References: When using a cell reference for the keyword, forgetting to use absolute references (e.g., using B1 instead of $B$1) causes the search term to shift down as you drag the formula.

Tips

  • Searching for Multiple Keywords: If you want to check if a cell contains "Apple" OR "Orange", use the OR function: =IF(OR(ISNUMBER(SEARCH("Apple", A2)), ISNUMBER(SEARCH("Orange", A2))), "Fruit", "Other").
  • Using Wildcards: While SEARCH handles partial matches naturally, you can use the asterisk (*) as a wildcard in other functions like COUNTIF or SUMIF if you need to perform calculations based on "LIKE" criteria.
  • Handling Empty Cells: To avoid getting a "Match" on empty cells or to keep the sheet clean, you can wrap your formula in another IF statement: =IF(A2="", "", IF(ISNUMBER(SEARCH("text", A2)), "Yes", "No")).

Troubleshooting

If your formula is not working as expected, try these steps in order:

  1. Check for trailing spaces: Sometimes cells contain hidden spaces (e.g., "Urgent "). Use the =TRIM(A2) function to remove extra spaces from your data before searching.
  2. Verify the error type: If you see #NAME?, check that all your function names (IF, ISNUMBER, SEARCH) are spelled correctly and that your text strings are inside quotes.
  3. Test the SEARCH part alone: Delete the IF and ISNUMBER parts and just run =SEARCH("text", A2). If it returns #VALUE!, the text is definitely not in the cell. If it returns a number, the search is working, and the issue lies in your IF logic.
  4. Check Data Types: Ensure the cell you are searching is formatted as "General" or "Text." If it is formatted as a Date or Number, the SEARCH function may behave unexpectedly.

Frequently Asked Questions

Is there a "LIKE" function in Excel?

No, Excel does not have a dedicated LIKE function. You must combine IF, ISNUMBER, and SEARCH to achieve the same result.

Does the SEARCH function care about capital letters?

No, the SEARCH function is case-insensitive. If you need to distinguish between "USA" and "usa", use the FIND function instead.

Can I search for a phrase instead of a single word?

Yes. You can put any string of text, including spaces and punctuation, inside the quotation marks (e.g., "Project Manager") and the formula will look for that exact sequence of characters.

How do I make the formula return a blank cell instead of "No"?

In the "value_if_false" part of the IF function, use two double quotes with nothing between them: =IF(ISNUMBER(SEARCH("text", A2)), "Yes", "").

Will this work in Google Sheets?

Yes, this formula structure is identical in Google Sheets and will function exactly the same way.