Using IF in Excel for Text: Compare, Match, and Return Results

Formulas & functions · Updated November 20, 2026

Yes. In Excel, IF can test whether a cell contains particular text and return one result when it does and another when it does not. With a payment status in A2, for example, use =IF(A2="Paid","Complete","Follow up"); it returns Complete when A2 contains Paid and Follow up otherwise.

How IF works with text

The IF function follows this structure: =IF(logical_test,value_if_true,value_if_false). The logical test must resolve to TRUE or FALSE. Excel then returns the second argument when the test is true, and the third argument when it is false. The returned values can be text, numbers, references to other cells, or formulas.

In a formula, text values must be enclosed in straight double quotation marks. Cell references are not quoted: A2 refers to the value in A2, while "Paid" is the literal word Paid. The commas separate the three arguments in standard English-language Excel settings. If your Excel uses semicolons as its list separator because of regional settings, replace the commas with semicolons when entering the formula.

With a customer status in A2, the formula =IF(A2="Active","Send renewal","No action") returns Send renewal for Active and No action for any other value. That includes a different status, a blank cell, or a misspelling. This default behavior matters: IF does not automatically identify which unexpected value appeared; it simply takes the false branch.

Return a text label or another cell’s content

Use text in quotation marks when you want a fixed message or category. This is useful for labels such as Approved, Check, Late, or Not found. Keep the wording consistent if another formula, filter, or PivotTable will use those labels later.

With a decision in A2 and a related message in B2, =IF(A2="Yes",B2,"") returns the content of B2 when A2 is Yes; otherwise, it returns an empty text string. Because B2 is a cell reference, its current content is returned rather than the literal characters B2.

The empty text string, written as "", makes a result look blank. It is not the same as leaving the formula cell genuinely empty: the cell still contains a formula, and functions such as COUNTA can count it as nonempty. Use this approach when you want to suppress an unwanted display, but remember that downstream formulas may still treat the formula cell differently from a truly blank cell.

Compare text and account for capitalization

A direct comparison such as A2="Paid" is not case-sensitive in a normal Excel comparison. It treats Paid, PAID, and paid as equal. That is usually convenient for statuses entered by different people, but it may not suit product codes, passwords, or other values where capitalization is meaningful.

With a code in A2, use =IF(EXACT(A2,"ABC"),"Match","No match") to require the exact capitalization ABC. EXACT returns TRUE only when the two text strings match, including their letter case. It does not remove spaces or otherwise clean the text first, so a trailing space can still prevent a match.

For ordinary comparisons, check for extra spaces if a value that looks correct is taking the false branch. With a status in A2, =IF(TRIM(A2)="Paid","Complete","Follow up") removes leading and trailing ordinary spaces, as well as reducing repeated spaces between words, before comparing. TRIM does not remove every possible invisible character, such as all kinds of nonbreaking spaces copied from websites, so imported data may need additional cleaning.

Find text inside a longer cell

Equality tests require the cell’s text to match the test value as a whole. If A2 contains a longer note such as Payment is late, testing A2="late" is false. To check whether a phrase occurs anywhere in a cell, SEARCH is often a straightforward option.

With a note in A2, use =IF(ISNUMBER(SEARCH("late",A2)),"Review","OK"). SEARCH returns the position where late begins when it finds the text, and ISNUMBER turns that result into TRUE. If SEARCH cannot find the word, it returns an error; ISNUMBER makes the test FALSE instead, so IF returns OK. SEARCH is not case-sensitive.

If capitalization must match, FIND can replace SEARCH. With a note in A2, =IF(ISNUMBER(FIND("Late",A2)),"Review","OK") finds Late but not late. FIND, like SEARCH, looks for a substring and returns an error when no match exists; wrapping it in ISNUMBER makes it suitable as an IF test.

COUNTIF offers another option when you want wildcard matching. With a note in A2, =IF(COUNTIF(A2,"*late*")>0,"Review","OK") checks for late anywhere in the cell. In a COUNTIF criterion, an asterisk represents any number of characters and a question mark represents one character. A tilde can escape a wildcard when you need to search for a literal asterisk or question mark. Wildcards do not work as special matching symbols in a plain comparison such as A2="*late*"; that comparison looks for those actual characters.

Test more than one condition

For decisions that depend on multiple requirements, combine tests with AND or OR inside IF. AND is true only when every supplied condition is true. OR is true when at least one condition is true. The function names and syntax work in current Microsoft 365 Excel on Windows, Mac, and the web.

With a payment status in A2 and an order amount in B2, =IF(AND(A2="Paid",B2>=100),"Priority","Standard") returns Priority only when the status is Paid and the amount is at least 100. Otherwise it returns Standard. In this example, the amount test is numerical; the text test remains a quoted text comparison.

With a response in A2, =IF(OR(A2="Urgent",A2="Escalated"),"Act now","Queue") returns Act now when either listed status is present. For longer lists of categories, nested IF formulas can become hard to read and maintain. Consider a lookup table or a more structured approach rather than building a very long chain of conditions.

Handle blanks and unexpected text

A common check is whether a cell is blank. With an optional comment in A2, =IF(A2="","Missing","Present") returns Missing when A2 is empty or contains a formula that returns an empty string. It returns Present when A2 contains visible text. This can be useful for data-entry checks, though it does not treat a cell containing spaces as blank.

If users might enter spaces, test the trimmed value instead. With an optional comment in A2, =IF(LEN(TRIM(A2))=0,"Missing","Present") treats an empty cell or a value made only of ordinary spaces as missing. TRIM and LEN are standard Excel functions. If the data comes from a web page or another system, unusual whitespace characters can require further cleanup.

When a formula should distinguish a known value from everything else, choose the false result deliberately. Returning Other, Check entry, or Unrecognized can make mistakes easier to spot than returning a blank. For example, a list of valid statuses can be checked with a separate validation rule, while an IF formula can provide a readable message. IF itself does not verify that a value belongs to an approved list.

Common problems and troubleshooting

  • Missing quotation marks: Write literal text as "Paid". Without quotation marks, Excel may interpret a word as a name or report a formula problem.
  • Curly quotation marks: Formulas require straight double quotation marks. Text copied from a formatted document may contain curly quotes that Excel does not recognize as formula delimiters.
  • Unexpected false result: Check for leading or trailing spaces, spelling differences, punctuation, or a value that is not actually the text it appears to be. Imported data can contain invisible characters.
  • Wrong argument separator: If Excel rejects commas, your regional settings may require semicolons. Use the separator Excel expects in your installation.
  • Blank-looking output: An IF result of "" looks empty but is still a formula result. It may behave differently from a truly empty cell in counts or later calculations.
  • Formula displayed as text: Check whether the cell is formatted as Text or the entry begins with an apostrophe. Set the cell to General, then re-enter the formula if needed.

In Microsoft 365 Excel for Windows, Mac, and Excel for the web, the basic IF formulas described here use the same function syntax. The ribbon locations and keyboard shortcuts can vary by platform, but no special menu command is required to write a text test. Some installations use localized function names or regional separators, so follow the syntax suggested by the formula bar if it differs from the examples.

Choose the right kind of text test

The best formula depends on what you mean by a match. A direct comparison is the clearest choice for a complete status or category. EXACT is appropriate when letter case matters. SEARCH or FIND is suited to finding a substring inside a longer note. COUNTIF with wildcards is useful when the condition is a pattern, such as text beginning or ending with certain characters.

Think about what should happen when the test fails. A useful formula usually makes that outcome explicit: return a meaningful label, show a review message, or deliberately display a blank. For a growing set of categories, a lookup table is often easier to update than a long nested IF. For a handful of conditions, IF with AND or OR is usually more readable.

These formulas calculate results in cells; they do not change the original text. If you want to visually highlight cells based on their text, use Conditional Formatting instead. If you want to prevent invalid text from being entered, use Data Validation. Those features solve related but different problems: IF returns a value, Conditional Formatting changes appearance, and Data Validation controls allowed input.

Frequently Asked Questions

Can IF return words in Excel?
Yes. Put the desired words in double quotation marks in the true and false result arguments. IF can also return a cell reference or another formula result.

Is an IF text comparison case-sensitive?
A direct equality comparison is generally not case-sensitive. Use EXACT inside IF when uppercase and lowercase letters must match precisely.

How do I check whether a cell contains a word?
Use SEARCH inside ISNUMBER as the IF condition for a case-insensitive substring check. Use FIND instead when capitalization should matter.

Can IF check for a blank cell?
Yes. A comparison with an empty text string can detect a blank cell and a formula result that looks blank. If cells may contain spaces, trim the value before checking it.

Why does my formula return the wrong result even though the text looks right?
Check capitalization requirements, extra spaces, spelling, hidden characters, and whether the cell contains text or a different kind of value. Also confirm that the formula uses straight quotation marks and the correct argument separator.

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.