CPE

Conditional Formatting Based on a Formula Part I

6 min read
conditional-formatting-based-on-formula-1-listing-image_edited

Excel’s conditional formatting capability allows the user to format cells based on the contents of a cell. In our June-August 2017 newsletters, we discussed the built-in conditional formatting capabilities of Excel (Top Bottom Rules, Highlight Cells, Data Bars, Color Scales, and Icon Sets.) In the next few newsletters, we will show how you can use Excel formulas to create complex formatting rules.

To utilize Excel’s Conditional Formatting with a formula option we proceed as follows:

  1. Select the range where the formatting will be applied.
  2. After selecting Conditional Formatting from the Home Tab select New Rule.
  3. Choose Use a Formula.
  4. With the cell in the upper left-hand corner of selected range type in a formula starting with =.
  5. This formula will copy across and down-selected range (watch your $ signs!) Whenever the copied formula is True, the desired format will be used.

In the file Beckerfeb2020.xlsx we illustrate the use of the Conditional Formatting with a Formula capability. Column E of the worksheet Amazon (see Figure 1) contains quarterly revenues for Amazon.com (in millions of dollars.) When revenue increased from the previous quarter, we want to highlight the revenue in green and when revenue decreased, we want to highlight the revenue in red.

conditional-formatting-based-on-formula-1-body-image-01

Figure 1 Amazon.com Data.

To begin, we select the cell range E6:E85 where we want to apply the format. Then from the Home tab, we choose Conditional Formatting and choose New Rule Use a Formula. Now think about what must be true for E6 to be formatted in green. We need E6>E5. If this formula is copied down then whenever the formula is True (see Column F), we should format the quarter’s revenue in green. Therefore, we fill in the Select a Rule Type dialog box as shown in Figure 2. After clicking OK, all revenues that were larger than the previous quarter are highlighted in green.

conditional-formatting-based-on-formula-1-body-image-05

Figure 2 Creating the Formula to format Revenues in Green

We want to format cell E6 in red if E6<E5. If this formula is copied down then whenever the formula is True (see Column G, we should format the quarter’s revenue in green. Therefore, we fill in the Select a Rule Type dialog box as shown in Figure 3. After clicking OK, all revenues that were smaller than the previous quarter are highlighted in red.

conditional-formatting-based-on-formula-1-body-image-03

Figure 3 Creating the Formula to Format Revenues in Red

As shown in the worksheet Format (see Figure 4) the revenues that were larger than the previous quarter are highlighted in green and the revenues that were smaller than the previous quarter are highlighted in red.

conditional-formatting-based-on-formula-1-body-image-04

Figure 4 Revenue increases are highlighted in Green and Revenue decreases are highlighted in Red.

Note that Column E is highlighted in Green if and only if Column F contains TRUE Green and Column E is highlighted in Red if and only if Column G contains TRUE.

If your cursor is anywhere in the range (E6:E85) where the format was applied, selecting Manage Rules from the Conditional Formatting menu will show you the conditional formats (see Figure 5) applied to that range.

conditional-formatting-based-on-formula-1-body-image-05

Figure 5 Manage Rules shows the Conditional Formats applied to the Range E6:E85

Next month, we will show you more complex examples that further illustrate the amazing capabilities of the Conditional Formatting with a Formula option.

Share

FacebookLinkedinXEmail
CPE FREE COURSE
Sidebar CTA
Browse our CPE Offerings

About the author

Dr. Wayne Winston is a Professor Emeritus of Decision Sciences at the Kelley School of Business at Indiana University. He holds a B.S. in Mathematics from M.I.T. and a PhD in operations research from Yale. He won more than 40 teaching awards at Indiana University. He has written more than a dozen books including "Marketing Analytics", "Data Analysis and Decision Making", "Operations Research", "Practical Management Science", "Office 365 Data Analysis and Business Modeling", and "Mathletics." Dr. Winston has taught classes and consulted for many leading global organizations. He is also a two-time Jeopardy! champion and has consulted for the NBA’s Dallas Mavericks and New York Knicks. His Linkedin class on Forecasting has been completed by over 250,000 learners. He has also published 30 research articles.

Featured

How to take a random sample in Excel
How to take a random sample in Excel
Read More
How to use Excel text functions
How to use Excel text functions
Read More
How to use slicers in Microsoft Excel
How to use slicers in Microsoft Excel
Read More

Now Leaving Becker.com

You are leaving the Becker.com website. Once you click “continue,” you will be brought to a third-party website. Please be aware, the privacy policy may differ on the third-party website. Adtalem Global Education is not responsible for the security, contents and accuracy of any information provided on the third-party website. Note that the website may still be a third-party website even the format is similar to the Becker.com website.

Continue