Turning a Cell Red when a Threshold is Exceeded

Written by Allen Wyatt (last updated August 6, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

At his office, Wally is responsible for making sure that aircraft are maintained on a set scheduled based on the number of hours they have accrued in flight time. He uses Excel to track the amount of flight time for each aircraft. In cell F1 he has the "threshold" for when maintenance should occur, as a number of hours. Wally needs a way to make the cell containing each aircraft's total flight time turn red once that total is within 5 hours of the threshold in F1.

This can be easily handled with conditional formatting, with one proviso: the accrued flight hours need to be stored as numeric values, not as date or time values.

You can test whether this condition is met by simply changing the formatting of one of the cells containing accrued flight hours. For example, let's say that cell D2 shows 3.5 accrued flight hours. Select that cell and change its format to General. If the resulting display still shows 3.5, then you are fine. If it shows something different, there is a good chance that the cell doesn't contain the numeric number of flight hours. In that case, you'll need to do a conversion on the hours to get what you need:

=ROUND(MOD(D2,1)*24,2)

This formula strips off the portion of the value that is before the decimal point (this portion represents a date and we are only interested in the time) and then rounds it to two decimal places.

Once you have the accrued flight time expressed as a numeric value, you can then create the conditional formatting rule you need:

  1. Select all the cells that contain accrued flight hours.
  2. Make sure the Home tab of the ribbon is displayed.
  3. Click the Conditional Formatting tool in the Styles group. Excel displays a palette of options related to conditional formatting.
  4. Click Manage Rules. Excel displays the Conditional Formatting Rules Manager dialog box.
  5. Click New Rule. Excel displays the New Formatting Rule dialog box.
  6. In the Select a Rule Type area at the top of the dialog box, choose Format Only Cells that Contain.
  7. In the Edit the Rule Description area, change the first drop-down list to Cell Value. (It may actually be this by default.)
  8. Change the second drop-down list to Greater Than or Equal To.
  9. In the area just to the right of the drop-down lists enter the formula "=$F$1-5" (without the quote marks). Note that you must include the equal sign, otherwise Excel can't figure out that you are entering a formula.
  10. Click Format to display the Format Cells dialog box.
  11. Use the controls in the dialog box to indicate how you want the accumulated flight hours to appear if they surpass 5 less than the threshold value.
  12. Click OK to dismiss the Format Cells dialog box. The formatting you specified in step 11 should now appear in the preview area for the rule.
  13. Click OK. The New Formatting Rule dialog box disappears and Excel again displays the Conditional Formatting Rules Manager dialog box. The rule you just defined is listed in the dialog box.
  14. Click OK. Excel applies the conditional formatting to whatever cells you selected in step 1.

If you prefer to not use a conditional formatting rule (perhaps you already have some other such rules in play), you could also rely on a custom format to do the formatting. In this approach, though, you don't rely on what is in cell F1. Instead, you need to "hard wire" the trigger value into the format. For instance, if your threshold in F1 is 500 hours, then your trigger value would be 495 hours. Follow these steps:

  1. Select all the cells that contain accrued flight hours.
  2. Right-click the range to display a Context menu, from which you should choose Format Cells. Excel displays the Format Cells dialog box.
  3. Make sure the Number tab is displayed.
  4. In the Category list, choose Custom. (See Figure 1.)
  5. Figure 1. The Number tab of the Format Cells dialog box.

  6. In the Type box enter "[Red][>=495]#,##0;[<495]#,##0;;" (without the quote marks).
  7. Click OK.

Now any accrued hours that are less than 495 will display normally and anything over that will show up in red. This approach does have some benefits (custom formats don't get messed up like conditional formatting sometimes does), but it means that if your trigger value changes at some point in the future, you'll need to modify the custom format directly.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13496) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

A Picture Is Worth a Thousand Words

Nothing beats a screen shot when you are trying to convey information about using the computer. With just a couple of ...

Discover More

Inserting Endnotes

Endnotes appear at either the end of a section or the end of an entire document. It is just as easy to insert an endnote ...

Discover More

Moving an Entire Page

If you are new to using Word, you may wonder if there is an easy way to move pages around in the document. Word, though, ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Working with Multiple Conditions

When you apply conditional formatting, you are not limited to using a single condition. Indeed, you can set up multiple ...

Discover More

Highlighting Cells Containing both Letters and Numbers

Conditional formatting is a great tool for changing the format of cells based on whether certain conditions (rules) are ...

Discover More

Conditional Formats for Odd and Even Columns

Setting up conditional formatting can be challenging under some circumstances, but once set it can work great. Unless, of ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 9?

2022-08-07 17:16:25

Dave Bonin

FWIW, I greatly prefer to use custom number formats (Allen's second method) over conditional formatting.

Why?

Because custom number formats are much more stable than conditional formats and do not suffer from the latter's "breeding problem".


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.