Sub topic 1
What Conditional Formatting Does and Where to Find It
Prerequisites
This chapter assumes you can already do the following in Google Sheets:
- Move around a spreadsheet and switch between sheet tabs.
- Type values and simple formulas, such as
=SUM(B2:B10), into cells. - Select a range such as
A2:F100by dragging or by typing it into the Name box.
You do not need to know custom formulas yet. Later chapters cover them step by step. This chapter builds the working model that the rest of the tutorial depends on.
What conditional formatting is
Conditional formatting is a feature that changes how a cell looks based on a rule. The rule tests the cell's value, or the result of a formula, and applies a format when the test is true. When the test is false, the cell keeps its normal appearance.
Three properties of this feature shape everything else in the tutorial.
- It changes appearance only. The cell's value, formulas, and number format stay untouched. If a rule turns a cell red, the cell still contains the same number or text.
- It is live. Sheets re-evaluates rules whenever the data changes. If you edit a score from 72 to 91, the highlight updates without any action from you.
- It belongs to a range, not to a cell. Each rule stores the range it applies to, along with a condition and a format. A sheet can hold many rules, and several can overlap on the same cells.
Compare this with formatting a cell by hand. Manual formatting is static: you paint a cell yellow and it stays yellow even after the data changes. Conditional formatting ties the color to the data, so the sheet keeps itself accurate.
What a rule can change
A rule can set the following style properties:
| Property | Available in a rule |
|---|---|
| Text color | Yes |
| Fill (background) color | Yes |
| Bold | Yes |
| Italic | Yes |
| Underline | Yes |
| Strikethrough | Yes |
| Font family and size | No |
| Borders | No |
| Number format (dates, currency) | No |
| Cell value | No |
If you need a border or a number format to change with the data, conditional formatting cannot do it. A common workaround is to leave the border in place permanently and use fill color as the signal.
What a rule cannot do
Knowing the limits early saves time later.
- It cannot be read by formulas. No function returns "the fill color of this cell." If you want to count highlighted rows, count with a formula that uses the same condition as the rule, such as
COUNTIF. - It cannot send alerts. A rule only changes how a cell looks. It does not email anyone or trigger a script. Notifications are a separate feature.
- It does not change the data. Sorting, filtering, and copying values work on the underlying values, not on the colors the rules produce.
How a rule is evaluated
A rule has three parts: the range it covers, the condition it tests, and the format it applies. Sheets checks the condition once for every cell in the range. When the condition is true for a cell, Sheets applies the format to that cell.
The per-cell check is the idea to hold on to. A rule covering A2:A100 is really 99 separate tests, one per cell. For built-in conditions such as "Greater than," each cell is compared to the threshold using its own value. For custom formulas, the formula is adjusted for each cell according to relative and absolute references. The chapter on references covers that in detail.
When more than one rule covers the same cell, Sheets checks the rules in the order they are listed. A later chapter explains how that order decides which format wins.
The three kinds of rule
The sidebar offers two tabs, and the first tab contains two styles of rule. Together they make three kinds:
- Single color rules apply one format to every cell that meets a condition. Conditions include "Text contains," "Greater than," "Is empty," and "Custom formula is."
- Color scale rules shade each cell on a gradient according to where its value falls between a minimum and a maximum.
- Custom formula rules are single color rules whose condition is a formula you write. They are the most flexible kind, and they are the reason this tutorial's title runs "from basic rules to custom formulas."
The next chapters take these in order. Here, the goal is only to know where each one lives.
Where to find it
Conditional formatting is opened from a menu command, and it works through a side panel rather than a dialog box.
Opening the sidebar
Use any of these routes:
- Select the cells you want to format, then choose Format from the menu bar and click Conditional formatting.
- Right-click a selected cell or range. In many versions of Sheets the command sits under View more cell actions, then Conditional formatting.
- Press
Alt+/(Option+/on a Mac) to open the menu search box, type "conditional," and press Enter.
Selecting the range first matters. When the sidebar opens, Sheets pre-fills the Apply to range box with your current selection, which saves you from typing it.
Reading the sidebar
The sidebar is titled Conditional format rules. Its contents change depending on whether you are looking at the list of existing rules or editing one.
When a sheet has no rules yet, the sidebar goes straight to a blank rule form. When rules exist, it shows them as a list. Each entry in the list shows the range, a short description of the condition, and a preview swatch of the format. Click an entry to edit it, or click Add another rule to create a new one.
The rule form has these controls, from top to bottom:
| Control | Purpose |
|---|---|
| **Apply to range** | The cells the rule covers. You can type a range, click the grid icon to pick one, or list several ranges separated by commas. |
| **Single color** and **Color scale** tabs | Choose the kind of rule. |
| **Format cells if** (single color) | A drop-down list of built-in conditions, ending with **Custom formula is**. |
| **Value or formula** box | The threshold or text the condition compares against. It appears for conditions that need one. |
| **Formatting style** | Pick text color, fill color, bold, italic, underline, and strikethrough. A preview shows the result. |
| **Done** and **Cancel** | Save the rule or discard your changes. |
The rule takes effect only when you click Done. Closing the sidebar with the X before that discards an unsaved rule.
A first rule, end to end
This short walkthrough shows the full path once. Later chapters explain each choice in depth.
Suppose column B holds exam scores in B2:B20, and you want scores of 80 or more to show in green.
- Select
B2:B20. - Open Format, then Conditional formatting.
- Confirm that Apply to range shows
B2:B20. - Under Format cells if, choose Greater than or equal to.
- In the Value or formula box, type
80. - Under Formatting style, click the fill color icon and choose a light green.
- Click Done.
Every score of 80 or above now has a green fill. Change a 78 to 85 and its color changes at once. Change it back and the green disappears. The numbers in column B never changed during any of this.
The same idea works for text. Choosing Text is exactly and typing Done would color every cell in the range whose entire content is "Done." Text conditions are not case sensitive, so "done" matches too.
A first look at a custom formula
Built-in conditions test one cell against one value. They cannot say "color this cell based on a different cell in the same row." Custom formulas can. Here is the first one from this tutorial's set, shown only so you recognize its shape:
=$C2="Done"Applied to A2:F100, it highlights each whole row whose column C value is "Done." The $ in front of C keeps the test pointed at column C for every column in the range, and the row number is left free so each row tests its own column C cell. You are not expected to write this yet. The chapters on references and custom formulas build up to it.
The formula in a rule must produce TRUE or FALSE. In the rule form, you write it starting with = in the box that appears after you choose Custom formula is. The rule is written relative to the top-left cell of the range, which is why the example uses row 2 for a range starting in row 2.
Behavior worth knowing early
These facts affect nearly every project, and most are easier to learn now than from a surprise later.
Rules travel with copy and paste
If you copy a cell and paste it normally, the pasted cells receive the source cell's conditional formatting along with its values. Sheets then adjusts or splits the rules' ranges to cover the new location. This is convenient, but it can quietly create many small rules. If you paste the same cell fifty times, you may end up with a long rule list. To avoid it, use Paste special and choose Values only, or paste Conditional formatting only when you want to copy the formatting alone. The chapter on managing rules covers cleanup.
Inserting and deleting rows changes ranges
When you insert a row inside a rule's range, the range grows to include it. When you insert a row just below the range, the range does not grow. If a rule covers A2:A100 and you add data in row 101, the new row is not formatted. This is a frequent cause of "the formatting stopped working" reports. Choosing a range that extends past your current data, such as A2:A1000, avoids it.
Formulas evaluate on every recalculation
Conditions that use volatile functions such as TODAY() re-evaluate when the sheet recalculates. A rule that flags dates earlier than today will start flagging a date as soon as the day rolls over, even if no one edits the sheet. Rules are not one-time actions.
Hidden and filtered rows keep their rules
Rules apply to hidden and filtered-out rows as well. The formatting is simply not visible until the rows are shown again. Rules do not stop working when a filter is applied.
Sharing and permissions
Anyone with edit access to a sheet can add, change, and delete its rules. Viewers and commenters see the colors but cannot open the rule list to change it. If you publish or share a sheet as view-only, the formatting appears as designed.
How this chapter fits the rest of the tutorial
The remaining chapters go from the sidebar's basic controls to the trickiest ones, in this order:
- Choosing the range a rule applies to.
- Single color rules with built-in conditions.
- Color scales for numbers.
- Relative and absolute references.
- Custom formula rules and their common patterns.
- Rule order, plus editing, copying, and deleting rules.
- Using data from another sheet with
INDIRECT. - Troubleshooting rules that misbehave.
The range comes first because every other choice depends on it. A correct condition on the wrong range still highlights the wrong cells.
Exercise
A teammate says, "I colored the overdue invoices red with conditional formatting, so I can now sum the amounts of the red cells with a formula." Explain what is wrong with this plan, and what they could do instead.
Show answer
Formulas cannot read the format of a cell, including colors that come from conditional formatting. No function returns "the fill color of this cell," so a sum over red cells is not possible. Instead, they should write the sum from the same condition the rule uses. For example, if overdue means the due date in column D is before today and the amount is in column E, they could use SUMIF with the condition on column D: =SUMIF(D2:D100,"<"&TODAY(),E2:E100). The rule shows the overdue invoices, and the formula calculates with the same logic.
Exercise
A rule covers A2:A100 and highlights values greater than 50. You type a new value of 75 in A101, and it is not highlighted. Why, and how would you fix it?
Show answer
The rule's range ends at A100, so A101 is outside it and the rule never tests that cell. Open Format > Conditional formatting, click the rule, and change Apply to range to a larger range such as A2:A1000, then click Done. Choosing a range that extends past the current data avoids the problem for future rows.
Exercise
List the three ways to open the conditional formatting sidebar, and name the control you should check first after it opens.
Show answer
Choose Format > Conditional formatting; right-click the selection and look under View more cell actions for Conditional formatting; or press Alt+/ (Option+/ on a Mac), type "conditional," and press Enter. After it opens, check the Apply to range box, which Sheets pre-fills from your selection, to confirm the rule covers the cells you intend.