Sub topic 1
What conditional formatting does and where to find it
Prerequisites
This chapter assumes you can do the following in Excel:
- Enter and edit data in worksheet cells.
- Apply basic formatting, such as a fill color or font color, from the Home tab.
- Write a simple formula such as
=A1+B1. - Select a range of cells with the mouse or keyboard.
You do not need to know any conditional formatting yet. The chapter builds the working model that the rest of the tutorial relies on.
What conditional formatting does
Conditional formatting changes how a cell looks based on a condition. The condition is either the cell's own value or the result of a formula. When the condition is true, Excel applies the formatting you chose. When it is false, the cell shows its normal formatting.
Two properties of this feature shape everything that follows:
- It is a display layer. The cell's value, formula, and number content never change. Only the appearance changes.
- It is live. Excel re-evaluates the condition whenever the data or a referenced cell changes. If a value drops below a threshold, the highlight disappears with no action from you.
Compare this with manual formatting. If you fill a cell red because a value looks too high, the fill stays red after the value is corrected. A conditional rule removes the fill on its own.
A small example
Suppose column C holds monthly sales figures in C2:C50. You want every figure over 1000 to appear in a red fill. The manual approach is to scan the column and fill cells one by one, then redo it whenever the numbers change. With a rule, you define the condition once:
=$C2>1000This is a formula-based rule. You will write rules like this in a later chapter. For now, note that one short condition replaces all the manual work and keeps itself up to date.
What a rule consists of
Every conditional formatting rule has three parts.
| Part | Meaning | Example |
|---|---|---|
| Range | The cells the rule is applied to (called "Applies to") | C2:C50 |
| Condition | The test Excel runs on each cell in the range | Value is greater than 1000 |
| Format | What the cell looks like when the condition is true | Light red fill with dark red text |
A cell can have several rules, and a range can have many rules overlapping. Excel evaluates each cell in the range independently. The same rule can highlight some cells and leave others unchanged.
The rule families
Excel groups its built-in rules into five families. Later chapters cover each in detail. This overview is enough to choose the right one.
- Highlight Cells Rules. Compare each cell with a value, a piece of text, a date, or the other cells. Includes Greater Than, Less Than, Between, Equal To, Text that Contains, A Date Occurring, and Duplicate Values.
- Top/Bottom Rules. Rank the cells in the range. Includes Top 10 Items, Top 10 %, Bottom 10 Items, Bottom 10 %, Above Average, and Below Average.
- Data Bars. Draw a bar inside each cell. The bar length shows the cell's value relative to the rest of the range.
- Color Scales. Shade each cell on a gradient of two or three colors, so low, middle, and high values are visible at a glance.
- Icon Sets. Place a small icon, such as an arrow, traffic light, or flag, in each cell according to which band the value falls in.
The first two families apply a fixed format to cells that meet a condition. The last three apply a graded visual that varies from cell to cell.
Beyond the five families, a New Rule option lets you build a rule from scratch. Its most powerful choice is "Use a formula to determine which cells to format". Formula-based rules can express anything the built-in rules cannot, such as highlighting a whole row based on one column.
Where to find it
On the Home tab, in the Styles group, click Conditional Formatting. The drop-down menu has these entries:
- Highlight Cells Rules
- Top/Bottom Rules
- Data Bars
- Color Scales
- Icon Sets
- New Rule...
- Clear Rules
- Manage Rules...
The first five open submenus of ready-made rules. New Rule opens the dialog for custom rules. Clear Rules removes rules from the selection or the whole sheet. Manage Rules opens the Conditional Formatting Rules Manager, where you review, edit, reorder, and delete the rules in effect.
Menu location in other versions
- Excel for Windows and Mac: the Home tab layout above applies. On a narrow window, the Styles group may collapse into a single Styles button. Click it to reach the Conditional Formatting button.
- Excel for the web: a smaller set of rule types is available, and some formula-based features are limited. Build complex rules in the desktop app.
- Keyboard: press
Alt, thenH, thenLin Windows to open the menu.
Applying your first rule
Follow these steps with any column of numbers.
- Select the range you want to format, for example C2:C50. The selection becomes the rule's Applies to range.
- Choose Home > Conditional Formatting > Highlight Cells Rules > Greater Than....
- In the dialog, type a threshold such as
1000. The dialog previews the result live on your data. - In the with list, pick a preset format such as "Light Red Fill with Dark Red Text", or choose Custom Format... to build your own.
- Click OK.
Now edit one of the highlighted values so that it drops below 1000. The highlight disappears. Change it back and it returns.
Open Manage Rules and pick "This Worksheet" in the Show formatting rules for list. You will see the rule you just created, with its condition, its format sample, and its Applies to range. Getting into the habit of checking this window is the quickest way to understand why a cell looks the way it does.
What you can and cannot format
A conditional format is limited compared with the full Format Cells dialog. The Custom Format dialog for a rule offers these tabs:
- Number: change the number format, for example to show negatives in red or hide zeros.
- Font: change style (bold, italic), underline, strikethrough, and color.
- Border: add thin borders. Thick borders are not available.
- Fill: background color, pattern, or gradient effects.
You cannot change the font name or the font size with a conditional rule. If your rule seems to be missing options, this is why. Data bars, color scales, and icon sets have their own controls in place of this dialog.
Behavior to know early
These points cause most of the surprises that new users report.
- Conditional formatting overrides manual formatting. If a cell has a yellow fill from the Fill Color button and a rule sets a red fill, the cell appears red while the rule is true. When the rule turns false, the yellow returns. The manual formatting is still there underneath.
- Rules travel with copy and paste. Copying a cell and pasting it normally copies its rules too. This can silently fragment one rule into many, each covering a small range. Chapter material on copying and clearing rules returns to this.
- Sorting and filtering keep the rules attached to the cells. Row-based rules written with a correct mixed reference keep working after a sort. Rules with wrong references often give wrong highlights afterward.
- Rules apply only to the range listed. Inserting rows inside the range extends it. Adding data beyond the last row does not, unless you extend the Applies to range or use a Table, where ranges grow with the data.
- Blank cells are treated as zero by many numeric rules. A rule such as "Less Than 10" can highlight empty cells. A formula-based condition can exclude blanks explicitly.
- Filtering by color works with rule colors. In a filter drop-down, Filter by Color lists the colors produced by conditional formatting, so you can combine highlighting and filtering.
Choosing a family
Use this guide as a starting point.
| Goal | Start with |
|---|---|
| Flag values above, below, or equal to a number | Highlight Cells Rules |
| Find repeated entries | Highlight Cells Rules, Duplicate Values |
| Show the largest or smallest items | Top/Bottom Rules |
| Compare magnitudes in a column | Data Bars |
| See the spread across a grid | Color Scales |
| Sort values into categories | Icon Sets |
| Format a whole row from one column, or test two columns together | New Rule with a formula |
When the built-in menus cannot express your condition, the answer is almost always a formula-based rule, which the later chapters teach.
Exercise
You apply a Greater Than 1000 rule to C2:C50. A cell containing 1200 turns red. You then change that cell to 900. What happens to the cell's fill, the cell's value, and the rule?
Show answer
The red fill disappears because the condition is now false, so Excel shows the cell's normal formatting. The cell's value is 900, since conditional formatting never changes content. The rule is unchanged and still applies to C2:C50, ready to highlight the cell again if the value rises above 1000.
Exercise
Where do you find the command to review all rules on a worksheet, and which entries in the same menu create a custom rule and remove rules?
Show answer
Go to Home > Styles > Conditional Formatting. Manage Rules... opens the Conditional Formatting Rules Manager, where you set "Show formatting rules for" to "This Worksheet" to see every rule. New Rule... creates a custom rule, and Clear Rules removes rules from the selected cells or the entire sheet.
Exercise
A cell has a yellow fill applied with the Fill Color button, and a conditional rule that sets a red fill is currently true for it. What color does the cell show, and what happens when the rule becomes false?
Show answer
The cell shows red, because conditional formatting takes priority over manual formatting. When the rule becomes false, the cell shows the yellow fill again, since the manual fill was never removed.