Yes. In Google Sheets, an IF statement can test text and return text: use =IF(A2="Paid","Complete","Pending") to show Complete when A2 contains Paid and Pending otherwise. Put text that you type directly into a formula inside double quotation marks; cell references do not need quotation marks.
How the IF function works
IF evaluates a condition, then returns one value when the condition is true and another when it is false. Its structure is =IF(logical_expression, value_if_true, value_if_false). The condition can compare a cell with text, test a number, or check a more involved expression. The two result arguments can be text, numbers, references, or other formulas.
For a text comparison, use an equals sign and enclose the text in double quotes. With product statuses in A2:A10, the formula below goes in B2 and can be filled down. For a row where A2 contains Paid, it returns Complete; for any other value, including an empty cell, it returns Pending.
With a status in A2, enter =IF(A2="Paid","Complete","Pending"). If A2 is Paid, the result is Complete; if it is Unpaid or blank, the result is Pending.
The quotes mark the text as a literal value rather than a name or reference. By contrast, A2 is a cell reference, so it is written without quotes. Quoting the reference as “A2” would make the formula compare against the two-character text A2, not the contents of that cell.
Text results and common patterns
IF is useful for converting coded values into readable labels, assigning a message to a condition, or producing a simple yes-or-no result. The result does not have to repeat the wording being tested. For example, a sheet can hold short entries such as Y and N while displaying longer descriptions in a report.
- Translate a code: With a code in A2, enter
=IF(A2="Y","Available","Unavailable"). If A2 is Y, the result is Available; otherwise, it is Unavailable. - Label a threshold: With a score in A2, enter
=IF(A2>=70,"Pass","Review"). If A2 is 70, the result is Pass; if it is 69, the result is Review. - Show text only for a match: With a status in A2, enter
=IF(A2="Late","Follow up",""). If A2 is Late, the result is Follow up; otherwise, the formula returns an empty text string, so the cell appears blank.
For each example, put the formula in the row where the referenced value is located, then copy it down if needed. Relative references such as A2 adjust to A3, A4, and so on when the formula is filled down. Check that the tested values use consistent spelling and avoid hidden spaces; a value such as Paid followed by a space may not match Paid.
Checking for text inside a cell
An equals comparison checks whether the entire cell value matches the specified text. It does not mean “contains these words.” To look for a word or phrase anywhere within a cell, SEARCH can locate the text and ISNUMBER can test whether a position was found. SEARCH is not case-sensitive, so it finds urgent in text such as URGENT or Urgent as well.
With notes in A2, enter =IF(ISNUMBER(SEARCH("urgent",A2)),"Review","Normal"). If A2 contains Please call urgently, the result is Review; if it contains Routine update, the result is Normal. If the search text is absent, SEARCH returns an error, but ISNUMBER converts that outcome to FALSE for IF.
SEARCH supports wildcard characters in its search text, which can be useful for matching variable text, but it is not necessary for an ordinary exact comparison. For a case-sensitive exact match, use EXACT instead. If the text might be absent and you use a different search approach that can produce an error, handle that possibility deliberately rather than assuming every search succeeds.
Combining text tests with AND and OR
AND requires every included condition to be true, while OR requires at least one condition to be true. These functions are often placed inside IF when a result depends on several text fields. They also make the logic easier to understand than a long chain of nested IF functions.
With a status in A2 and a manager approval in B2, enter =IF(AND(A2="Ready",B2="Approved"),"Schedule","Wait"). If A2 is Ready and B2 is Approved, the result is Schedule; if either condition is false, it is Wait.
With a region in A2, enter =IF(OR(A2="North",A2="West"),"Priority","Standard"). If A2 is North or West, the result is Priority; if it is South, the result is Standard. Use AND when all requirements must be met and OR when any one qualifying value is enough. For a short list of possible values, OR is easy to read; for a large list, a lookup table may be simpler to maintain.
Blank cells, spaces, and capitalization
A common use of IF is to show a message only after someone enters a value. Comparing a cell with an empty string checks for a blank-looking value, but a cell containing spaces is not truly empty. If users might enter stray spaces, TRIM can remove leading, trailing, and repeated spaces before the test.
With an optional note in A2, enter =IF(TRIM(A2)="","Missing","Entered"). If A2 is empty or contains only spaces, the result is Missing; if it contains a word such as Call back, the result is Entered. TRIM also changes the text used in the test, so choose it when cleaning spaces is appropriate for the data.
Ordinary text equality comparisons in Google Sheets are generally not case-sensitive. If the capitalization itself matters, EXACT is a case-sensitive test. With an approval value in A2, enter =IF(EXACT(A2,"Approved"),"Match","Check"). If A2 contains Approved with that capitalization, the result is Match; if it contains approved in lowercase, the result is Check.
Nested IF statements and easier alternatives
A nested IF puts one IF inside another to handle more than two outcomes. For example, a grading rule can distinguish three score ranges. Nesting is useful for a small number of clear cases, but each additional level makes the formula harder to inspect and easier to break when requirements change.
With a score in A2, enter =IF(A2>=90,"A",IF(A2>=80,"B","C or below")). If A2 is 92, the result is A; if it is 85, the result is B; if it is 75, the result is C or below. The order matters: the formula tests the highest threshold first, then checks the next threshold only if the first condition is false.
Google Sheets also has IFS for testing several conditions in sequence. It returns the result associated with the first condition that is true, so put conditions in an order that gives the intended outcome. For many categories that people may revise, storing the rules and corresponding labels in a small table and using a lookup can be more maintainable than editing a long nested formula. The best choice depends on how many cases there are and how often they change.
Common errors and how to fix them
If a formula gives an unexpected result, first separate the condition from the output labels. Confirm that the tested cell contains the value you think it does, and verify the exact spelling, punctuation, and spacing. A copied value may include a trailing space or a different apostrophe character. When appropriate, TRIM can address extra ordinary spaces, but it will not correct misspellings or different wording.
- Text is missing quotation marks: Put literal text in straight double quotation marks, as in
"Paid". Cell references remain unquoted. - The formula returns the false result: Check whether the entire cell equals the test value. Use SEARCH with ISNUMBER if the requirement is to find a phrase inside a longer entry.
- The formula appears as text: Check that the cell is not formatted as plain text and that the entry begins with an equals sign. Re-entering the formula after changing the format may be necessary.
- Google Sheets rejects the formula: In most locales, arguments are separated by commas. Some spreadsheet locales use semicolons instead, so the separator shown in examples may need to match the spreadsheet’s locale.
- A blank input shows an unwanted label: Add a blank check before the main test, or make the false result an empty string if that is the intended behavior.
Also distinguish text that looks numeric from a real number. A cell containing the text “70” may behave differently from the numeric value 70 in comparisons or calculations. If a condition depends on a numeric threshold, check how the source data is stored rather than relying only on how it looks on screen.
Google Sheets and Excel differences
The basic IF syntax and the examples above work in Google Sheets and are also familiar to Excel users. Both use double quotes around literal text and use an equals sign for an exact comparison. However, this page describes Google Sheets in a web browser; its menus, sharing features, and locale settings are not the same in every spreadsheet program.
In Google Sheets, you can review the spreadsheet’s locale through File > Settings. Locale can affect formula separators and other regional conventions. Do not assume that a formula copied from a workbook or an online example will use the same separator in every file. When moving a sheet between products, check the formula in the destination program and confirm that the result is unchanged.
Frequently Asked Questions
Can an IF statement return words in Google Sheets?
Yes. Put the words in double quotation marks in the true and false result arguments, such as =IF(A2="Yes","Approved","Declined"). If A2 is Yes, the result is Approved; otherwise, it is Declined.
How do I make IF return a blank instead of FALSE?
Give IF a third argument containing an empty text string. For example, with a status in A2, =IF(A2="Open","Active","") returns Active for Open and an empty-looking result for any other value.
Does IF match part of a text cell?
No. A condition such as A2=”urgent” tests the whole cell value. To check whether a cell contains a phrase, use SEARCH inside ISNUMBER, then use that test as IF’s condition.
Is Google Sheets text matching case-sensitive?
Ordinary equality comparisons are generally case-insensitive. Use EXACT inside IF when capitalization must match, such as distinguishing Approved from approved.
Why does my text IF formula not match?
Check for extra spaces, spelling differences, punctuation, and whether the condition tests the whole cell or only part of it. Also confirm that literal text is inside straight double quotation marks and that the formula uses the separator expected by the spreadsheet’s locale.
Related
- Average in Excel: How to Calculate It
- How to Find Duplicates in Excel Quickly and Accurately
- How to Find Duplicate Names in Excel Without Guessing
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Make Two Columns in a Word Document QuicklyTo make two columns in Microsoft Word for Microsoft 365 on Windows, select the text you want to…
- How to Add Just a Header in WordTo add only a header in Word, open the document and choose Insert > Header > Edit Header,…
- Outlook 365 Signature: How to Create and Set It UpTo create a signature in Outlook 365, open the signature settings for the Outlook version you use, add…
- Project Tracker Spreadsheet in Google Sheets: Setup GuideYes. You can make a project tracker spreadsheet in Google Sheets by creating a sheet with one row…
- Delete a Page Break in Word Without Losing Your TextTo delete a manual page break in Microsoft Word, show formatting marks, locate the line labeled Page Break,…
- Google Sheets Dropdown Calendar: How to Add a Date PickerYes—Google Sheets can show a calendar date picker in a cell, but it is not the same as…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.