An IF formula in Google Sheets can return text or a number, but it cannot directly change a cell’s fill color. To color cells according to a condition, use Format > Conditional formatting; you can use a built-in rule or a custom formula to make the color respond to your data.
Why an IF formula cannot set a cell color
The IF function evaluates a test and returns one result when the test is true and another when it is false. It changes the cell’s value, not its formatting. For example, it can display “Pass” or “Review” based on a score, but it cannot make the cell green or red as part of the formula.
With a score in B2, this formula returns “Pass” when the score is at least 70 and “Review” otherwise: =IF(B2>=70,"Pass","Review"). If B2 contains 82, the result is “Pass.” The cell’s fill color remains whatever formatting it already had. That separation is useful: formulas calculate content, while formatting controls how that content appears.
To make the color respond automatically as values change, set up a conditional formatting rule. You can base that rule on the cell’s value, text, date, or a custom formula. The rule applies visual formatting without changing the value produced by IF.
Color cells with a built-in conditional formatting rule
For straightforward tests, Google Sheets offers rule options that do not require writing a formula. To color scores below 70 in a column, for example:
- Select the range you want to format, such as B2:B100.
- Choose Format > Conditional formatting.
- In the conditional format rules panel, check that the “Apply to range” field contains the range you selected.
- Under “Format cells if,” choose a condition such as “Less than,” then enter
70. - Choose a fill color or text color under “Formatting style,” then select Done.
Values below 70 in the selected range will receive the chosen formatting. If a score changes to 70 or higher, it no longer meets that rule, so the conditional color is removed. You can use built-in conditions for options such as text contains, date is, is empty, and numeric comparisons. The available choices depend on the kind of condition you select.
Be careful to select the cells you intend to color before creating the rule. If you select only B2:B100, only those score cells are formatted. If you want an entire row to change color based on a score or status elsewhere in that row, use a custom formula instead.
Use a custom formula for IF-style color rules
A custom formula lets you express more specific logic, including combinations of conditions. In the conditional formatting panel, choose Custom formula is, enter a formula, set the style, and select Done. The formula should evaluate to TRUE for rows or cells that should receive the formatting.
Suppose column B contains scores, column C contains a status, and you want to highlight the full row from A through C when the score is at least 70 and the status is Active. Set “Apply to range” to A2:C100. Because row 2 is the first row of that range, use this custom formula: =AND($B2>=70,$C2="Active"). A row with a score of 82 and status Active meets both tests and gets the chosen color; a row with a different status does not.
The dollar signs matter. In $B2 and $C2, the column letters are fixed so the rule always checks columns B and C, while the row number can adjust for each row in the applied range. If the applied range begins on row 2 but the formula refers to row 1, the rule will check the wrong row. Match the formula’s starting row to the first row of the range.
For a simpler rule, if the text Overdue in column C should color each corresponding row in A2:F100, use =$C2="Overdue". The dollar sign before C fixes the status column; the row remains relative. A custom formula is often the clearest way to apply an IF-like visual decision across a table.
Show a label with IF and color it separately
You can combine an IF formula and conditional formatting when you want both a readable label and a color cue. For example, place a formula in D2 that labels a score in B2 as “Pass” or “Review.” With the score in B2, enter =IF(B2>=70,"Pass","Review"). If B2 contains 82, D2 displays “Pass.” Copy the formula down the column to evaluate other rows.
Then select D2:D100 and create a conditional formatting rule for text that is exactly “Pass,” choosing a green fill. Add another rule for text that is exactly “Review,” choosing a contrasting fill. The text remains available to readers and to other formulas, while the rules supply the visual distinction. If you prefer, apply the rules directly to the score range instead of adding a label column.
Using a label can make a sheet easier to scan, but it is not always necessary. If the color alone is enough and the decision is simple, a conditional formatting rule based directly on the score avoids an extra formula column. Consider keeping a text label for important statuses so the meaning is not conveyed by color alone.
Color a cell, a row, or text
The “Apply to range” setting determines which cells receive a conditional format. A rule can color a single cell, a column of values, or a rectangular block covering several columns. The condition can refer to a different cell from the one being colored, which is how a status in one column can highlight an entire row.
- Color one value column: Apply a score rule to B2:B100.
- Color a whole record: Apply a custom formula to A2:F100 and have it check a status column with a fixed column reference, such as
=$C2="Overdue". - Change text color: Choose a text color in the rule’s formatting style rather than, or as well as, a fill color.
Conditional formatting applies to cells; it is not a way to color just one word within a formula result. If you need different colors for portions of text inside a cell, conditional formatting is not the right tool. You can apply text formatting manually, but a formula’s returned text does not carry its own font or fill formatting.
Choose the right rule for your sheet
Use the simplest rule that clearly expresses the condition. Built-in rules are easier to read and maintain for basic checks such as “greater than 70” or “text contains Late.” A custom formula is more flexible when the condition involves multiple columns, several tests, or a relationship between cells.
Before adding a rule, decide whether the color should apply to the value cell or to its entire row. Also decide whether the test is based on a number, exact text, a date, or a formula result. These choices determine the applied range and rule type; choosing them deliberately helps avoid a color that appears in the wrong place.
For date-based checks, built-in date conditions can be convenient. For a more tailored condition, a custom formula can compare a date with a deadline or with today’s date. For instance, if due dates are in B2:B100 and you want to flag past dates, the formula depends on whether completed items should be excluded and where completion status is recorded. Define that logic first rather than coloring every old date automatically.
Common problems and how to fix them
- The color never appears: Confirm that the value actually meets the condition, the “Apply to range” field includes the cell, and the formatting style uses a visible color. For custom formulas, check that the formula begins with an equals sign and refers to the first row of the applied range.
- The wrong row is highlighted: Check the row number in the custom formula. If the range starts at row 2, a formula referencing row 1 can make each row depend on a different record than intended.
- Only one column changes color: The rule may be applied only to that column. Expand “Apply to range” to cover the whole row block if that is the intended effect.
- Numbers are treated like text: A value that looks numeric may have been entered or imported as text. Check the underlying cell value and formatting, and make sure the comparison is appropriate for the data.
- Different colors seem to conflict: Review the rules listed in the conditional formatting panel. Multiple rules may apply to the same cells; adjust their conditions, ranges, or order so the intended formatting is clear.
When a custom formula behaves unexpectedly, test its logic in an ordinary empty cell as well. A TRUE or FALSE result can show whether the condition itself is working before you troubleshoot the formatting range. Remove the test formula afterward if it is not part of the finished sheet.
Conditional formatting compared with manual color
Manual fill color is appropriate when the color is a one-time design choice, such as shading a heading. It does not automatically respond when a value changes. Conditional formatting is better for status indicators, score bands, deadlines, and other cases where the appearance should track the data.
A manual color can also make a sheet misleading if the underlying value changes but the fill does not. A conditional rule avoids that mismatch by recalculating the visual condition as the sheet updates. Conversely, avoid adding a complicated rule for a color that will never need to change; simple manual formatting is easier in that case.
Google Sheets conditional formatting is available in the browser through Format > Conditional formatting. Excel has its own conditional formatting features and menus, but its interface and some formula behavior can differ. The steps here describe Google Sheets, not Excel.
Frequently Asked Questions
Can an IF statement change a cell’s color in Google Sheets?
No. IF returns a value, such as text or a number. Use Format > Conditional formatting to change a cell’s displayed color based on a condition.
How do I make a cell green if it says “Yes”?
Select the cell range, open Format > Conditional formatting, choose a text condition such as “Text is exactly,” enter Yes, and choose a green formatting style. Confirm the applied range before selecting Done.
Can conditional formatting color an entire row?
Yes. Set the applied range to the rows and columns you want to shade, then use a custom formula that checks the relevant column. Fix the column with a dollar sign, such as =$C2="Overdue", and make the formula’s row number match the first row in the range.
Can I use IF inside conditional formatting?
You can use a custom formula for a conditional formatting rule, but IF is not usually needed: the rule applies its style when its formula evaluates to TRUE. AND and OR can express many multi-condition tests directly.
Can a formula return a colored result?
A formula can return text such as “Pass” or a symbol, but it cannot assign that result a fill or font color. Use a separate conditional formatting rule to style the cell based on the returned text or the underlying data.
A practical way to keep color meaningful
Use color consistently and make sure the sheet still communicates when color is difficult to distinguish or unavailable. Pair important colors with labels such as Pass, Review, or Overdue, and avoid relying on a color alone to explain what action a reader should take. With that approach, IF formulas can handle the decision, while conditional formatting provides a responsive visual cue.
Related
- How to Copy Format in Excel Without Copying Cell Data
- How to Insert a Specific Number of Rows in Excel Quickly
- How to Insert a Page Border in Excel for Printed Sheets
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 Insert a Horizontal Line in a Word DocumentTo add a quick divider in Word for Microsoft 365 on Windows, type three hyphens (—) on a…
- Add a Page Break in Excel: Steps, Layout, and Print TipsTo add a page break in Excel for Microsoft 365 on Windows, select the cell where the next…
- How to Unblock a Sender in Outlook Email on Any DeviceTo unblock a sender in Outlook, remove their email address or domain from your blocked senders list. In…
- Excel Table Color Not Changing? Common Causes and FixesIf an Excel table’s color is not changing, select a cell inside the table, open Table Design, and…
- Multiple Sort in Google Sheets: Sort by Two or More ColumnsYes. In Google Sheets, you can sort by multiple columns by selecting your data and choosing Data >…
- Outlook Calendar Share Request: How to Send and Manage OneTo share your Outlook calendar, open Calendar, choose Share Calendar or Share, enter the recipient, set their permission…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.