Excel's IF function has no LIKE operator, but you can get the same partial-match behaviour with the COUNTIF, SEARCH or ISNUMBER functions inside it. The most reliable pattern is =IF(COUNTIF(A2,"*text*")>0,"match","no match"), which returns TRUE when the cell contains your text anywhere. For case-sensitive matching, wrap SEARCH's logic in EXACT or use FIND instead, because SEARCH ignores case and FIND does not. This guide shows each pattern with worked examples, the wildcard rules behind them, and the reasons a formula that looks right still returns the wrong answer.

What You'll Need

  • Excel 2016 or later, Microsoft 365, or a recent Excel for Mac version. The formulas here also work in Excel for the web and in Google Sheets with minor differences noted below.
  • A column of text values to test. The examples assume the text sits in A2 and below, with the formula in B2.
  • Your regional list separator. In English-locale Excel for Windows this is a comma; in many European locales it is a semicolon. If Excel rejects a comma, swap it for your locale's separator.
  • Basic familiarity with relative references so the formula copies down correctly.

Step-by-Step

  1. Decide what "like" means for your data. There are three common cases: contained in the cell anywhere (*text*), starts with (text*), and ends with (*text). Write down which one you need before touching a formula; the wildcard position is the whole difference between them.
  2. Start with COUNTIF, the simplest option. In B2, enter =IF(COUNTIF(A2,"*garden*")>0,"Yes","No"). COUNTIF returns 1 when A2 contains "garden" anywhere and 0 when it does not, so the IF can act on it directly. This is the formula to reach for first because it accepts wildcards natively and needs no access to the exact characters of the match position.
  3. Copy the formula down. Drag the fill handle in the corner of B2 or double-click it to fill to the last row of your data. Check that the row references shift, not the search text. If you want one fixed search term stored in a cell (say D1), write it as "*"&D1&"*" and lock the cell with dollar signs: =IF(COUNTIF(A2,"*"&$D$1&"*")>0,"Yes","No").
  4. Handle multiple words with search text that contains wildcards. Wildcards inside your own search term get interpreted, not matched literally. If you are looking for "star*" written literally, COUNTIF will treat the asterisk as a wildcard. To search for a literal asterisk, tilde or question mark, precede it with a tilde: "*~*~*" matches a literal asterisk. This is a common surprise when your data holds part numbers or IDs.
  5. Use SEARCH when you also need the position or case-insensitive matching without COUNTIF. Enter =IF(ISNUMBER(SEARCH("garden",A2)),"Yes","No"). SEARCH returns the character position of the match or an error, and ISNUMBER turns that into TRUE or FALSE. SEARCH is case-insensitive, so "Garden", "garden" and "GARDEN" all match.
  6. Switch to FIND for case-sensitive matching. Replace SEARCH with FIND: =IF(ISNUMBER(FIND("Garden",A2)),"Yes","No"). Now "garden" in lower case will not match because FIND compares exact characters. Choose FIND only when upper/lower case genuinely matters, because it will otherwise miss real matches.
  7. Test the starts-with and ends-with patterns. For a cell beginning with the text, use =IF(COUNTIF(A2,"garden*")>0,"Yes","No"). For a cell ending with it, use =IF(COUNTIF(A2,"*garden")>0,"Yes","No"). The asterisk sits on the side that is allowed to have extra characters.
  8. Combine a partial match with another condition. To test text and a numeric threshold together, wrap the two in AND: =IF(AND(COUNTIF(A2,"*garden*")>0,B2>100),"Keep","Drop"). Each condition gets its own complete test; keep the comparisons separate rather than trying to chain them inside one COUNTIF.
  9. Verify against a known row. Type a value you know should match into an empty cell and point the formula at it. If the answer flips as expected, the logic is right; if not, the problem is almost always the wildcard placement, a stray space in the search string, or the wrong reference direction.

Common Mistakes

  • Writing =IF(A2 LIKE "*text*"). Excel has no LIKE keyword, so this is a syntax error. The same applies to SQL-style patterns carried over from other tools.
  • Using equals with wildcards. A2="*garden*" looks for those exact characters, not a partial match. Equals does not evaluate wildcards; COUNTIF and SEARCH do.
  • Forgetting that counts count cells. COUNTIF with a wildcard returns a count, not a Boolean. Comparing it with >0 is what turns it into a TRUE or FALSE the IF can use. Without that comparison you get a number where you expected a label.
  • Assuming SEARCH is case-sensitive. It is not. Realising this explains why "finding" and "Finding" both match and why the wrong casing never triggers a failure.
  • Trailing spaces in the source data. A cell holding "garden " with a space still matches a contained-text search, but a starts-with or ends-with search can fail. Use TRIM on the source column if the data came from a copy-paste or export.
  • Mixing up SEARCH and FIND in the wrong direction. SEARCH matches ignoring case, FIND matches case exactly. Reaching for FIND by default is the most common cause of missed matches.

Tips

  • Put the search term in its own cell and reference it. You can then change what you are looking for without editing a dozen formulas, and the sheet becomes far easier to audit.
  • Use *term* for the broadest match, then tighten to term* or *term if the broad version returns false positives such as "gardening" when you only wanted "garden".
  • In Google Sheets the equivalent works the same way with COUNTIF and SEARCH; use REGEXMATCH when your pattern needs more than a simple wildcard, which Excel cannot replicate with COUNTIF.
  • Wrap the whole formula in IFERROR if you want a clean output when a cell is empty: =IFERROR(IF(ISNUMBER(SEARCH("garden",A2)),"Yes","No"),"").
  • For a full-column count, use COUNTIF over the range rather than dragging the single-cell formula down, for example =COUNTIF(A2:A100,"*garden*"), when you only need a total.

Troubleshooting

If every row returns "No", check the wildcard position first: term* only matches text at the start, and a cell with the term in the middle fails. Confirm the search string has no leading or trailing spaces. If only some rows fail, look at the data for non-breaking spaces from web copy-paste; TRIM does not remove those, but SUBSTITUTE with CHAR(160) does.

If the formula shows the text of the formula instead of an answer, the cell is formatted as Text. Change the format to General and re-enter the formula. If you see #VALUE!, check the argument separator; a comma in a semicolon locale produces this. If the answer is inconsistent down the column, check whether your search term reference moved; freeze it with dollar signs if it should stay put.

If FIND returns "No" for text you can see on screen, the case is probably different. Switch to SEARCH if case should not matter. If COUNTIF returns a number where you expect a label, you have omitted the comparison and the IF's true and false results.

Frequently Asked Questions

Does Excel have a LIKE function?

No. Excel has no LIKE operator. Use COUNTIF with wildcards or SEARCH with ISNUMBER to achieve the same partial-match result inside an IF.

Is COUNTIF case-sensitive?

No, COUNTIF ignores case when matching text, so "Garden" and "garden" are treated the same. Use FIND inside ISNUMBER for a case-sensitive test.

Can I search for a literal asterisk or question mark?

Yes, put a tilde before it: ~* matches an asterisk and ~? a question mark. Without the tilde Excel treats them as wildcards.

Why does my wildcard search return the whole range count?

Because COUNTIF counts matching cells across the range you pass it. If you passed the whole column, every matching cell is counted; restrict the range or use the single-cell version inside IF.

Can I use multiple search terms in one formula?

Yes, nest two COUNTIF tests inside OR or AND: =IF(OR(COUNTIF(A2,"*red*")>0,COUNTIF(A2,"*blue*")>0),"Yes","No"). Each term needs its own COUNTIF call.

Do these formulas work in Excel for the web?

Yes, COUNTIF, SEARCH, FIND and ISNUMBER all work in the web version and in Excel for Mac. Only the argument separator differs by locale.