Excel Formula If Cell Contains Value: Practical Examples

Formulas & functions · Updated November 18, 2026

To return one result when a cell is not empty and another when it is empty, use =IF(A2<>"","Yes","No"). With the value to test in A2, this returns Yes when A2 contains a value and No when it is blank; if you mean a particular word or number inside the cell, use a text-search or matching test instead.

Check whether a cell is nonblank

The IF function evaluates a condition and returns one result if that condition is true and another if it is false. Its structure is =IF(logical_test,value_if_true,value_if_false). The not-equal operator, <>, makes the test A2<>"" mean “A2 is not equal to an empty text string.” This is a useful way to distinguish a filled-in cell from an empty one.

With an entry in A2 and the formula in B2, =IF(A2<>"","Entered","Missing") displays Entered if A2 contains a name, number, date, or other nonempty value; it displays Missing if A2 is empty. Replace those two result labels with any output that suits the task, such as a status, a number, or another formula.

To make the result blank when A2 is empty and show a message otherwise, with the same layout use =IF(A2<>"","Ready",""). The empty quotes in the final argument return an empty text string, so the formula cell looks blank. It still contains a formula, however, and is not truly empty.

Look for particular text anywhere in a cell

If “contains” means that a cell may include a word within a longer phrase, combine IF with SEARCH and ISNUMBER. SEARCH returns the starting position of the searched text when it finds a match, and an error when it does not. ISNUMBER turns that result into a true-or-false test that IF can use.

With descriptions in A2 and the result formula in B2, use =IF(ISNUMBER(SEARCH("apple",A2)),"Found","Not found"). If A2 contains Red apple pie, the result is Found; if it contains Pear tart, the result is Not found. SEARCH is case-insensitive, so it also finds APPLE or Apple.

This test looks for a sequence of characters, not a whole word. Searching for cat would also match category. If that distinction matters, a simple SEARCH formula may be too broad: use a more specific phrase, or design a test around the delimiters or word boundaries in your data. Excel does not provide a universal one-function “whole word” test for every kind of text.

To show a blank rather than Not found when the search text is absent, with descriptions in A2 use =IF(ISNUMBER(SEARCH("apple",A2)),"Found",""). This can make a report less cluttered, although a blank result can also make it harder to tell whether a check was performed.

Use exact matches when the whole cell must match

A contains test and an exact-match test answer different questions. If A2 must be precisely the word Approved, compare the entire cell directly rather than searching within it. With the status in A2 and the formula in B2, use =IF(A2="Approved","Proceed","Review"). Approved returns Proceed, while Approval pending returns Review.

Excel text comparisons using the equals operator are not case-sensitive. Therefore, this test treats approved and APPROVED as a match for Approved. If capitalization itself matters, with the status in A2 use =IF(EXACT(A2,"Approved"),"Proceed","Review"). EXACT distinguishes uppercase and lowercase letters, so only the same capitalization matches.

For an exact match against a number, compare the cell to the number without putting it in quotation marks. With a quantity in A2, use =IF(A2=10,"Target reached","Below or above target"). A text value that looks like 10 may not behave identically to the numeric value 10, so check how the source data is stored if an apparent match fails.

Test numbers, dates, and empty-looking cells

To test whether a value is above a threshold, use a comparison such as greater than or equal to. With a score in A2, =IF(A2>=70,"Pass","Review") returns Pass for 70 or more and Review for a lower score. This is a numeric condition, not a text-contains condition.

Excel stores dates as serial numbers, which means date comparisons can use ordinary greater-than and less-than operators. With a due date in A2, use =IF(A2<=DATE(2026,12,31),"Due by year-end","Later"). A date on or before December 31, 2026 returns Due by year-end. DATE builds the date from year, month, and day rather than relying on a regional date-text format.

Be aware that a cell that looks empty is not always empty. It may contain spaces, an apostrophe, or a formula that returns an empty string. The test A2<>"" treats a formula result of an empty string as empty, but spaces are still characters and count as content. ISBLANK, by contrast, returns TRUE only if the cell has no contents at all; a formula in the cell means it is not blank even if its displayed result is empty.

If leading or trailing spaces should not count as an entry, with text in A2 use =IF(TRIM(A2)<>"","Has meaningful text","Blank or spaces"). TRIM removes ordinary leading and trailing spaces and reduces repeated internal spaces to single spaces. It does not remove every possible nonprinting character, such as some nonbreaking spaces copied from websites, so imported data may need cleaning if the test still gives unexpected results.

Choose what IF returns

The true and false results can be text, numbers, or calculations. For example, IF can assign a value only after a required input is present. With units in A2 and a price per unit in B2, put this formula in C2: =IF(A2<>"",A2*B2,""). If A2 contains 3 and B2 contains 12, C2 returns 36; if A2 is empty, C2 displays a blank instead of multiplying.

This kind of check can prevent a result from appearing before a row is ready, but it does not validate every input. If A2 contains text where a number is expected, the multiplication may return an error. Add a suitable validation rule or an error-handling approach when the source data may be inconsistent.

For more than two outcomes, an IF can be placed inside another IF, though a long chain becomes difficult to read. For a small set of labels, consider IFS, which checks conditions in order. With a score in A2, use =IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"Below C"). A score of 85 returns B; the final TRUE supplies a fallback for values that meet none of the earlier conditions. IFS is available in Microsoft 365 and newer Excel versions, including Excel 2019 and later.

Apply a contains test to a list

To return a result for every row, write the formula beside the first row and fill it down. With descriptions in A2:A20, enter =IF(ISNUMBER(SEARCH("late",A2)),"Flag","") in B2, then copy it through B20. Each row checks its own description: A2 is checked in B2, A3 in B3, and so on. Excel adjusts the relative cell reference as the formula is copied.

To count cells containing a word rather than label each row, COUNTIF supports wildcard characters. With descriptions in A2:A20, use =COUNTIF(A2:A20,"*late*"). The asterisks mean that any characters may appear before or after late; the formula returns the number of cells containing that sequence. COUNTIF matching is not case-sensitive.

Wildcards are handy for counting, but they do not replace IF when each row needs a different returned result. Also, an asterisk in the search pattern has a special wildcard meaning. If the data contains a literal asterisk or question mark that must be matched, COUNTIF requires the tilde escape character before that symbol.

Common problems and how to fix them

  • The formula says Not found for a visible word: Confirm that the text is in the referenced cell, and check for unusual characters or a misspelled search term. SEARCH ignores capitalization, but it still requires the searched characters to appear in sequence.
  • A blank-looking cell is treated as filled: Look for spaces or other invisible characters. If ordinary spaces are the issue, TRIM can help; if the cell contains a formula returning an empty string, use a comparison with empty text rather than ISBLANK.
  • The formula returns an error: SEARCH returns an error when there is no match, which is why it is wrapped in ISNUMBER in the examples. If the formula directly uses SEARCH as the IF condition, a missing phrase can make the entire formula return an error.
  • The answer is the wrong type: Check whether a value is stored as text or as a number. A value imported as text may look numeric but fail a numeric comparison or calculation. Convert or clean the source data where appropriate.
  • The formula displays the formula instead of a result: Check that the cell is not formatted as Text and that the formula begins with an equals sign. After changing the format to General, re-enter the formula.

In Microsoft 365 for Windows, enter a formula in a cell and press Enter; use the fill handle to copy it down a column. On Mac, the formula syntax is the same, but common keyboard shortcuts differ: Windows uses Ctrl+C and Ctrl+V to copy and paste, while Mac uses Command+C and Command+V. Excel for the web also uses the same core formulas, though the interface and available keyboard shortcuts can vary by browser.

How to choose the right formula

Start by defining what “contains a value” means in the worksheet. These cases call for different tests:

  • Any nonempty entry: use a comparison such as A2<>””.
  • A phrase anywhere in the cell: use ISNUMBER with SEARCH for a case-insensitive contains test.
  • The entire cell must equal a label: compare the cell directly with the label; use EXACT if letter case matters.
  • A numeric limit or date range: use comparison operators such as >=, <, or <=.
  • A count of matching cells: use COUNTIF with wildcards rather than building a separate IF formula for each row.

Before copying a formula through a workbook, test it on representative examples: an empty cell, a normal match, a nonmatch, and any unusual data your sheet contains. This is particularly useful when cells include formulas, imported text, or inconsistent spacing. Clear labels for the true and false results also make the logic easier for someone else to audit.

Frequently Asked Questions

What is the simplest Excel formula if a cell is not blank?
With the cell to test in A2, use =IF(A2<>"","Yes","No"). Replace Yes and No with the results you need.

How do I check if a cell contains a specific word?
With the text in A2, use =IF(ISNUMBER(SEARCH("word",A2)),"Yes","No"). Replace word with the phrase to find. SEARCH is not case-sensitive and can match a sequence inside a longer word.

How do I make the result blank if the cell is empty?
With the input in A2, use =IF(A2<>"","Result",""). The final empty text argument makes the formula display nothing when A2 is empty.

What is the difference between ISBLANK and checking for empty text?
ISBLANK is true only when a cell has no contents, including no formula. Comparing a cell with empty text can treat a formula that returns an empty string as blank, which is often more useful for worksheet logic.

Does SEARCH distinguish uppercase and lowercase?
No. SEARCH is case-insensitive. Use FIND instead when the search must distinguish letter case; as with SEARCH, wrap the result in ISNUMBER when using it as an IF condition.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.