Conditional Formatting
Conditional Formatting
Conditional formatting
Conditional formatting is a great tool for visually highlighting cells that
contain values meeting conditions you specify, for example,
You set it up once and let it go. It’s like an automated detective. All you
need to do is glance at the results once in a while to see what the
detective has found.
3. Choose one of the top five menu options for predefined conditional
formats.
or
3. Choose New Rule to manually create a new formula to identify cells to
be formatted and specify the format.
or
3. Choose Manage Rules to modify, change the priority, or delete an
existing rule.
2. In Show Formatting Rules For select where the rules are located.
3. Choose New Rule, Edit Rule, or Delete Rule as needed. Change the
priority in which rules are applied by selecting a rule, click on its name,
then click the up or down arrow at the top of the list to move the rule up
or down.
Tip: You can step through selected cells to see their formulas while
maintaining the total selected range. To step through a selection cell-by-
cell, press Tab to move forward or Shift+Tab to move backward.
7. Deleting conditional formatting
To delete conditional formatting select the range, table, or Pivot Table
that has conditional formatting. (See Tip 6 above to learn how to select
the range.)
3. Select the Rule Type you want from the top list.
The New Formatting Rule dialog gives you the ability to customize conditional formatting.
5. The lower part of the Edit the Rule Description box changes so you
can customize the Rule Type. In this case, it shows options for
controlling icons. Choose Ok.
Use the last rule type, Use a Formula to Determine Which Cells to
Format, if the top five Rule Types do not give you capability. You will
need to use the “Use a Formula…” Rule Type if your conditional
formatting includes a complex formula or has AND, OR, and NOT
conditions.
9. Create dynamic conditional values by
referencing a worksheet cell
Remember that any Value box with a range selector icon,
can contain a cell reference as well as a static value. Click the range
selector icon to select a cell that will contain the value you want as a
condition. Putting the conditional value in a worksheet cell enables you
to change it easily as many of the advanced tips and download file show.
For example, you may want to reference cells on the worksheet that
contain dynamic values for Upper and Lower limits.
To display the Rules Manager, on the Home ribbon, in the Styles group,
select Conditional Formatting, then click Manage Rules.
The order of conditions in the Rules Manager is important.
The Rules Manager tests rules starting with the topmost rule and
working down. It applies formatting when a rules condition returns TRUE
and continues down the list if there are no conflicts in formats. See Tip
11 if you want the Rules Manager to apply no other formats after the first
TRUE condition.
Use this, if a rule at the top of the list formats the font to bold, and a
lower rule in the list formats the cell background to green. These formats
do not conflict so the Rule Manager might apply both bold and green
background to a cell meeting both conditions. However, if you never
want cells with bold font to have a green background you should select
Stop If True for the rule with bold font.
=$G5>=50
Create this formula as though it applies to the topmost cell in the Units
Sold column, $G5, and will be copied down through the entire range that
is receiving the conditional format. Because it is being copied across and
down this range, you don’t want column G to change. To fix column G
make it an Absolute reference, $G. However, the row must change as
the test condition is copied down all rows, so the row number uses a
Relative reference, 5 (with no $).
Here are a few simple rules for how to use Absolute and Relative
reference in conditional formatting.
In addition to original and conditional formats, you can use custom cell
formatting on numbers to apply color and numeric date formats unique to
positive, negative, zero, or text values.
One solution to this is to format the extra area around the PivotTable to
allow for possible expansion. If you do this, just remember that any
conditional format applied to this expansion area, such as shading
alternate rows, should appear with a correct format whether or not it is
occupied with the PivotTable data. (You don’t want alternating rows
highlighted where there is no data.)
The green up-arrow icon uses the upper-limit value stored in $G$2. The
red down-arrow icon uses the lower-limit icon stored in $H$2. Notice that
the Type is set to Number, not Percent.
16. Create custom conditional formatting for
complex conditions
When you need conditional formats that have rules too complex for
predefined conditional formats, then you need to create your own
formulas.
3. At the bottom of the Select a Rule Type list, select Use a Formula to
Select Which Cells to Format.
The New Formatting Rule dialog gives you the ability to customize conditional formatting.
4. In the Format Values Where this Formula is True, you must enter a
formula that returns TRUE when the conditional format should be
applied. The formula must result in TRUE for the formatting to be
applied. For example, you might use a formula like this to test whether
values in column B of a list are equal to the value in cell $B$5 outside
the list,
=$B25=$B$5
5. Click Format and define the format you want applied when this
condition is TRUE. Click Ok.
6. Click Ok.
=OR($E5=”Kludget”,$E5=”Flibbit”,$E5=”Flogjam”)
This is an illustration. In most cases you would want to make the text dynamic.
Copying the formula from cell I5 into the Rule Description area of the
New Formatting Rule or Edit Formatting Rule dialog box identifies which
rows will receive conditional formatting.
=$G5>=50
This formula was copied down I5:I26 to see if it returned the correct
TRUE and FALSE for rows to receive conditional formatting. Once the
formula returns valid results, the range to be conditionally formatting,
C5:H36, is selected and the formula can be entered into the New
Formatting Rule dialog box.
=$G5>=$J$4
$J$4 is the cell that receives a number from the Data Validation drop-
down list.
This formula was copied into I5:I26 to see if it returned the correct TRUE
and FALSE for rows to receive conditional formatting. Once the formula
returns valid results, the range to be conditionally formatting, C5:H36, is
selected. Then the formula is copied into the New Formatting Rule dialog
box.
itical to Success
MENU
You set it up once and let it go. It’s like an automated detective.
All you need to do is glance at the results once in a while to see
what the detective has found.
The New Formatting Rule dialog gives you the ability to customize conditional formatting.
5. The lower part of the Edit the Rule Description box changes so
you can customize the Rule Type. In this case, it shows options
for controlling icons. Choose Ok.
Use the last rule type, Use a Formula to Determine Which Cells to
Format, if the top five Rule Types do not give you capability. You
will need to use the “Use a Formula…” Rule Type if your
conditional formatting includes a complex formula or has AND,
OR, and NOT conditions.
9. Create dynamic conditional values by
referencing a worksheet cell
Remember that any Value box with a range selector icon,
The Rules Manager tests rules starting with the topmost rule and
working down. It applies formatting when a rules condition returns
TRUE and continues down the list if there are no conflicts in
formats. See Tip 11 if you want the Rules Manager to apply no
other formats after the first TRUE condition.
=$G5>=50
The New Formatting Rule dialog gives you the ability to customize conditional formatting.
=$B25=$B$5
5. Click Format and define the format you want applied when this
condition is TRUE. Click Ok.
6. Click Ok.
=OR($E5=”Kludget”,$E5=”Flibbit”,$E5=”Flogjam”)
This is an illustration. In most cases you would want to make the text dynamic.
Copying the formula from cell I5 into the Rule Description area of
the New Formatting Rule or Edit Formatting Rule dialog box
identifies which rows will receive conditional formatting.
=$G5>=50
=$G5>=$J$4
$J$4 is the cell that receives a number from the Data Validation
drop-down list.
This formula was copied into I5:I26 to see if it returned the correct
TRUE and FALSE for rows to receive conditional formatting.
Once the formula returns valid results, the range to be
conditionally formatting, C5:H36, is selected. Then the formula is
copied into the New Formatting Rule dialog box.
=MOD(ROW(),2)=0
In this formula the ROW function returns the row number of the
formula’s cell. MOD then finds the modulo, or the remainder when
the row number is divided by 2. When this is 0, then the formula
returns 1. Excel interprets 1 as TRUE so the row is formatted. If
the formula returns 0, which Excel interprets as FALSE, the row is
not formatted. The result is formatting on alternating rows.
The conditional formula has the text values hard coded into the formula,
=OR($E5=”Kludget”,$E5=”Flibbit”,$E5=”Flogjam”)
In most cases, you would want to make the text condition dynamic.
=OR($E5=$F$2,$E5=$G$2,$E5=$H$2)
The values in $F$2, $G$2, and $H$2 are entered using a Data
Validation drop-down list stored in K5:K12. The value “- None –“ is in the
list so that a non-matching selection can be chosen when needed.
Because “- None –“ begins with a hyphen/minus sign, you must precede
it with an apostrophe (‘).
What makes this especially powerful is that the text in F2 can use the
wildcards * to match any group of characters or ? to match against any
single character.
While the logic of the formula is convoluted, the resulting ability to format
with wildcards searches is powerful.
=AND($C5>=$D$1,$C5<=$D$2)
The Sales Date for each row is tested to be in the range between Date
Start in $D$1 and Date End in $D$2. When the Sales Date is within the
range the formula returns TRUE so the row is formatted.
TIP: When you allow users to enter a date range you can reduce errors
by using Data Validation to limit the range of dates they can enter, as
shown in this example. Another method of reducing errors is to use a
slider or drop-down list for date selection.
=OR(ISBLANK($C5),ISBLANK($D5),ISBLANK($E5),ISBLANK($F5),ISB
LANK($G5),ISBLANK($G5),ISERROR($H5))
Be aware that blanks are different than zeroes. Test for blanks with
ISBLANK. Test for zero values with =0.
You can create heat maps in Excel using just the simplest of conditional
formats. Make sure your data are arranged so that there is a relationship
between data points and real-world distribution. For example,
temperature measurements would be shown over the geographic points
where a temperature was taken.
This heat map is in two tabs in the example file. One tab has the “reveal”
that shows the mathematics and scroll bars that make it dynamic. The
other tab shows the finished heat map and scroll bars that allow you to
move the hotspot. (It uses a binomial distribution (bell-shaped curve) of
values at 20 points across the X- and Y-axis. Sliding the X or Y sliders
moves the hotspot on the map.)