0% found this document useful (0 votes)
42 views4 pages

ENGG1811 How-To Guide: Understanding Conditional Formatting

1) Conditional formatting dynamically applies cell formatting based on conditions involving cell values and formulas. Formulas used in conditional formatting are evaluated relative to the last selected cell. 2) An example conditionally formats cells to have a pink background if their value is greater than 6. Making the cell reference absolute correctly formats cells when the condition is copied. 3) To conditionally format an entire row based on a cell in that row, a formula comparing the cell to a value is used rather than a cell value condition. The formula cell reference must be mixed (absolute column, relative row) to correctly format when copied.

Uploaded by

billy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views4 pages

ENGG1811 How-To Guide: Understanding Conditional Formatting

1) Conditional formatting dynamically applies cell formatting based on conditions involving cell values and formulas. Formulas used in conditional formatting are evaluated relative to the last selected cell. 2) An example conditionally formats cells to have a pink background if their value is greater than 6. Making the cell reference absolute correctly formats cells when the condition is copied. 3) To conditionally format an entire row based on a cell in that row, a formula comparing the cell to a value is used rather than a cell value condition. The formula cell reference must be mixed (absolute column, relative row) to correctly format when copied.

Uploaded by

billy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ENGG1811 How-To Guide: Understanding Conditional Formatting

Key Learning Outcomes

1. Understand how conditional formatting dynamically applies styles to cell ranges based on
contents of the sheet
2. Be able to apply conditional formatting to cells using simple comparisons
3. Understand how cell references in formulas are interpreted when conditional formatting is
applied
4. Be able to apply conditional formatting to cells using formulas
5. Be able to apply conditional formatting to ranges using formulas relating to other cells

Part 1. How Conditional Formatting Works


Conditional formatting applies a single style to a single cell or group of cells, based on conditions that are
evaluated whenever the sheet changes. The style overrides any existing formatting the cell may have.
Conditions can be
• a comparison between a cell value and a constant
• a comparison between a cell value and a value determined by a formula
• completely determined by a formula
In all cases any cell addresses used in a formula are evaluated with respect to a reference cell, the last cell
selected. If they aren't absolute addresses they will be adjusted the same way formulas are when copied.
Identifying the reference cell is crucial to getting the formulas exactly right.

Part 2. Using Conditional Formatting


On a new sheet enter the first 9 odd numbers and the first 6 even numbers in a 3-column by 5-row range
starting at (say) C2:

Now highlight the middle column, select Conditional Formatting from the Format menu. keep the default
condition type (Cell value is) and against the first condition select greater than and enter 6 in the box:

1
To be sure you can notice the
applied style it's best to make a
new one. Press New Style...,
enter PinkBkg in the Name box
and select a light pink colour
(probably Magenta10) from the
Background tab. Press OK, and
then OK on the Conditional
Formatting dialogue box.
Not surprisingly, the cells in the
selected range that have values
greater than 6 now have a pink
background. To show it's
dynamic, temporarily change one
of the smaller values in that
column to be larger, and a large
one to be 6 or less. Restore the original numbers.
Select the range again from top to bottom and re-select Conditional Formatting. The condition should still
be there, replace the constant 6 by the absolute cell reference $E$5. Click OK, there's no change as
expected. Repeat the task, but this time remove the $ so it's just E5. The cells should look like this:

That's funny, 3 isn't normally greater than 6! To see what happened, click on the middle cell, the one
containing 15. Its condition, as shown in the Conditional Formatting box, is “greater than E3”, not the E5 we
typed. E3 is one row up and one column right
of the central cell. That's because E5 is a row
up and a column right of the highlighted cell,
which was the active cell when we entered
the formula. Cell D2 is highlighted because 3
is greater than the empty cell E1.
In this case the relative column reference
makes no difference, because there's only
one column. If we applied this condition to column C as well, then the formulas applied to that column
would point to column D, one to the right. If we used $E in the formula, they would point there.

Important conclusion
When using a formula to define conditional formatting, assume you are entering it for the
active cell (the last cell selected), and it will be copied to all cells in the selected range. Use
the appropriate addressing type (absolute, relative or mixed) according to how you want
the formula interpreted.

2
Part 3. Using the Formula is Condition type
Once you've got the idea of how formulas are interpreted, you can apply this to tasks like highlighting rows
of data based on some characteristic of a cell in each row or on adjacent rows. In this case you use the
Formula is type rather than Cell value is, because that allows you to make a decision based on values in any
cells, not just the one whose highlighting is being considered.
Once again, the formula will be evaluated against the reference cell, the one that ended the drag range.
For a fairly simple example, copy the following data, including headers, into a blank area of the spreadsheet,
starting with F10.
Solar System Body Mass, x 1021kg Natural Satellites
Sun 1989100000 8
Mercury 330.2 0
Venus 4868.5 0
Earth 5973.6 1
Mars 641.85 2
Jupiter 1898600 63
Saturn 568460 62
Uranus 86832 27
Neptune 102430 13

We're interested in solar system bodies that are more than 15 times the mass of Earth. We could highlight
just the mass column with a Cell value is condition referring to G14 (the cell containing Earth's mass). Which
of the following would achieve this? (Answer overleaf).
A: Cell value is greater than 15*G14
B: Cell value is greater than 15*G$14
C: Cell value is greater than 15*$G14
D: Cell value is greater than 15*$G$14
To highlight the entire row of the table (columns F, G and H) we can't use such a formula without saying
which cell compares to the Earth's mass. Call that cell X. It's obvious that X always has to refer to the G
column (absolute reference), and X must be on the same row as the cell we want to highlight, so it's a
relative reference. Putting that together, we have
1. The formula must be of the form X > 15*$G$14 (when we work out what X is), because the cell
to be highlighted can be anywhere in the table, so the G14 reference must be absolute, $G$14.
2. If we drag the range from top to bottom and left to right, the active cell ends up at H19. We
therefore enter the formula as if we were highlighting row 19, but let the row reference be relative.
Thus X is the mixed reference $G19.

3
Assuming we create a new style FatPlanet with greenish background and a bold font, the desired effect is
achieved:

Not covered
Multiple conditions. These are tested in order. As soon as one condition is true, that style is applied. If none
of the conditions is true, no style is applied.
Geoff Whale
06-Mar-2014

Answer B or D. D is safest, but B also works because only one column is involved so G doesn't have to be absolute.

You might also like