IF Formula – Set Cell Color w/ Conditional Formatting – Excel & Google Sheets
Written by
Reviewed by
Last updated on June 30, 2022
This tutorial will demonstrate how to highlight cells depending on the answer returned by an IF statement formula using Conditional Formatting in Excel and Google Sheets.
Highlight Cells With Conditional Formatting
A cell can be formatted by conditional formatting based on the value returned by an IF statement on your Excel worksheet.
- First, create the IF statement in Column E.
=IF(D4>C4,”Overdue”,”Ontime”)
- This formula can be copied down to Row 12.
- Now, create a custom formula within the Conditional Formatting rule to set the background color of all the “Overdue” cells to red.
- Select the range you want to apply formatting to.
- In the Ribbon, select Home > Conditional Formatting > New Rule.
- Select Use a formula to determine which cells to format, and enter the formula:
=E4=”OverDue”
- Click on the Format button and select your desired formatting.
- Click OK, and then OK once again to return to the Conditional Formatting Rules Manager.
- Click Apply to apply the formatting to your selected range and then click Close.
The formula entered will return TRUE when the cell contains the word “Overdue” and will therefore format the text in those cells with a background color of red. - To format the “OnTime” cells to green, you can create another rule based on the same range of cells.
- Click Apply to apply to the range.
Highlight Cells If… in Google Sheets
The process to highlight cells that contain an IF Statement in Google Sheets is similar to the process in Excel.
- Highlight the cells you wish to format, and then click on Format > Conditional Formatting.
- The Apply to Range section will already be filled in.
- From the Format Rules section, select Custom Formula and type in the formula.
- Select the fill style for the cells that meet the criteria.
- Click Done to apply the rule.