Google Sheets Conditional Formatting: Formulas and Examples

Published:

Updated:

google sheets conditional formatting

Disclaimer

As an affiliate, we may earn a commission from qualifying purchases. We get commissions for purchases made through links on this website from Amazon and other third parties.

Part of our Productivity Tools guides

Google Sheets conditional formatting can automatically highlight cells, rows, or columns when they meet a rule. You choose the cells, set a condition, and pick a visual style. The feature helps you scan spreadsheet data faster.

A bright status or overdue date can stand out in a busy sheet. That can help you find details that shape daily tasks and business decisions. You can use a simple color or a formula-based rule for more specific needs.

Start with a useful range and a clear condition, then choose a style you can read at a glance. A clear visual cue can help you spot a value that needs attention without scanning every row.

Key Takeaways

  • Choose the cells or rows you want a rule to check.
  • Use one color for a clear match and a scale for numeric values.
  • Use a custom formula when another cell controls the style.
  • Check the apply-to range and rule order when a style looks wrong.
  • Try a rule on a small range before using it across a large sheet.

What a Conditional-Formatting Rule Changes

A conditional-formatting rule tells Sheets which cells to check and how to display them when they meet a condition. The rule changes appearance, not the value stored in a cell. Each rule has an apply-to range, a condition, and a formatting style.

The apply-to range is the cell, row, or column where a conditional-formatting rule can take effect. The condition sets the test, such as whether a value equals a word or exceeds a number. The formatting style sets the visual change, such as a new text or background color.

For example, a project sheet might show “Ready” in a status cell when a task can move ahead. You could make that cell green when its value matches “Ready.” The text stays the same, but the color makes the status easier to spot.

A rule can cover one cell, a group of cells, or a full column. The same condition can help you scan a short list or a large set of data. A useful range keeps the highlight focused on the information you need.

Before you set a rule, think about what action a highlighted value should prompt. A status might signal follow-up, while a number might show a target was missed. Decide which value or status deserves attention before choosing a color.

Google Sheets Conditional Formatting: Set Up a Rule

You can create a basic rule in a few steps, starting with the cells you want Sheets to check. Apply conditional formatting to a selected range, then choose a condition and style. Check the Apply to range field before saving, so the rule reaches only the cells you intend.

  1. Select the cells you want the rule to check.
  2. Open Format > Conditional formatting.
  3. Confirm or enter the range in the Apply to range field.
  4. Choose a condition and formatting style in the panel.
  5. Click Done to save the rule.

You can enter a range in the panel instead of selecting cells first. For example, type A2:A50 to target those cells. The Apply to range field lets you set or adjust the target cells while you build formatting rules.

Selecting a whole column applies the rule to that column. You can select its letter at the top, or type a column range in the field. This is useful when new rows may be added later.

Pause on the range field before you save. A misplaced start or end cell can affect data outside your intended area. If the rule should cover only status cells, make sure the range does not include nearby notes or totals.

The panel offers Single color and Color scale. The right choice depends on what you need the sheet to show, not on how much color looks best. You can change the style later if the result is hard to read.

Confirm the Apply to range field before clicking Done.

Choose a Single Color or a Color Scale

A digital workspace displays numeric values in colored sections, shifting from cool blues and greens for low values to reds and oranges for high values. A clear ruler lies across the foreground, with a modern home office in the background.
Choose a single color or a color scale to highlight values in Google Sheets, using a gradient to distinguish low numbers from high ones.

Use a single color to flag a specific condition and a color scale to see how numeric values compare across a range. Single color fits a clear match, such as a status word. A color scale works best when values have a meaningful low-to-high order.

Single-color rules can test text, numbers, or dates. The cell gets your chosen style when it meets the condition. A scale instead shades values by their place between set points.

Rule typeHow it worksSettingsExample
Text rulesMatch words or text patternsText is exactly “Late”Color late task statuses red
Number or date rulesTest a number or dateGreater than 100Flag sales above $100
Color scalesShade values across a rangeMinimum and maximum, with optional midpointShow low-to-high monthly totals

A single-color rule gives a direct signal: the condition matches, or it does not. For example, a red fill can mark a date before today. This kind of formatting keeps a list easy to scan without implying more than one state.

A color scale uses minimum and maximum values and can include an optional midpoint. A darker shade might mark larger totals, while a lighter shade marks smaller ones. That helps you compare numbers without reading each value in order.

A scale is a poor fit for categories such as team names. A gradient suggests that one name falls between two others on a numeric range. For text labels, use a single-color rule that checks the category you want to flag.

Choose a scale only when the values have a meaningful low-to-high order.

Use Custom Formulas to Format Related Cells

A laptop on a wooden desk displays a colorful Google Sheets spreadsheet, with conditional formatting highlighting cells in column B across selected rows. A coffee cup, notebooks, and a potted plant sit nearby, with framed photos and wall art in the home office.
Custom formulas can format related cells based on spreadsheet data, highlighting selected rows in column B in Google Sheets.

A custom formula lets you format one range based on a value in another cell. Choose Custom formula is in the rule panel, then enter a formula Sheets can test. The formula must return a condition Sheets can evaluate as true or false.

A custom formula can format selected cells based on another cell on the same sheet. To refer to a cell on another sheet, use INDIRECT. The same-sheet method can mark a row when its status cell meets a chosen condition.

Build a Rule from Another Cell’s Value

For example, apply the formula =$B1=”Yes” to the selected range A:E. Sheets checks column B in each row, then formats the selected cells when that row contains “Yes.” This can make a whole line stand out when one status changes.

The dollar sign before B locks the column reference, so the formula keeps checking column B across columns A through E. The row number stays flexible, so each row checks its own status cell. The formula’s row number should match the first row of the selected range.

If formulas are new to you, a guide to Google Sheets formulas and cell references can help explain how references shift. That idea matters when a custom formula is applied across several cells.

Lock the Reference for Row-Wide Formatting

Dollar signs control which part of a cell reference stays fixed as the rule checks other cells. These four styles behave differently across a selected range.

Reference styleWhat stays fixedWhat can adjust
A1NothingColumn and row
$A1Column ARow number
A$1Row 1Column letter
$A$1Column A and row 1Nothing

For a row-wide rule, lock the column that holds the test value and leave the row number free to change. If the selected range begins on row 2, use a formula that starts with row 2. Match the formula’s starting row to the first row in the Apply to range field.

Examples for Duplicates and Text Patterns

A custom formula can flag every repeated value in a selected range, while text rules can match flexible patterns. Use a duplicate check when repeated entries need review. The COUNTIF example highlights every copy of a value that appears more than once.

Highlight Duplicate Values

To find duplicates in A1:A100, apply this formula to the exact range A1:A100:

=COUNTIF($A$1:$A$100,A1)>1

The formula counts how often each cell’s value appears in the full range. A count above one makes the condition true, so every repeated instance gets the chosen style. This can reveal duplicate IDs, names, or invoice numbers in a list.

Use the range that holds the values you want to check. If you apply the formula to a different range, adjust the references to match it. That keeps the test focused on the right set of cells.

Match Text with Wildcards

Text contains and Text does not contain rules support wildcards. A question mark (?) matches any single character, while an asterisk (*) matches zero or more characters. These marks can help find patterns without typing every possible word.

For example, a?c matches abc, but it does not match ac. The question mark requires one character between “a” and “c.” The asterisk can stand for a longer stretch, or no characters at all.

Put a tilde before a wildcard to match that character itself. Use ~? to find a question mark or ~* to find an asterisk in the text. This is useful when the symbol appears in the data as punctuation, not as a pattern.

When your sheet needs more repeated checks, Google Sheets automation with Apps Script can help with tasks beyond cell formatting. For a quick review, keep the conditional rule focused on the exact pattern or range.

Check whether you want every copy of a duplicate flagged, since this COUNTIF rule highlights all repeated instances.

Manage Rules and Check Them on Mobile

If a cell keeps the wrong style, check whether a rule above it is already true. Rule order matters when more than one condition matches the same cell. The first true rule in the list defines the format.

You can drag rules to change their order. A rule higher in the list gets checked first, so place the rule you want to take priority above the others. One custom formula can also combine conditions with AND, such as =AND(L2=TRUE,G2>12).

On Android, you can create custom-formula rules and view rules that intersect a selected range or all rules on the sheet. That makes it easier to inspect formatting while working away from a computer.

  • Confirm the Apply to range.
  • Check rule order.
  • Remove an unneeded rule with its trash icon.

If a change affects more cells than expected, Google Docs version history guidance can help you understand how version history works across Google files. You can also review past edits to a spreadsheet in Google Sheets.

On Android, select the range you need to inspect or view all rules on the sheet.

Conclusion

A well-chosen rule makes the information that matters easier to spot. Clear conditions keep colors tied to a useful action, while a readable style helps people scan the sheet. One focused highlight can make a busy spreadsheet easier to use.

Try one rule on a small, useful range and check how it looks beside the surrounding data. If the color hides text or draws attention to the wrong value, change the style or narrow the range. Start with one range and one condition, then adjust the style if the result is hard to read.

FAQ

How to code conditional formatting in Google Sheets?

Choose Custom formula is and enter a formula that starts with an equals sign. The formula should return TRUE or FALSE based on the cells you want to check. For example, a formula can test whether a status cell says “Yes.” Set the range the rule should affect, then choose a style for matching cells.

How to make a cell highlight if condition is met?

Select the cell or range, choose a matching condition, and pick a formatting style. Click Done to save the rule. For example, you can set a text condition that matches “Late,” then choose a red background. The cell’s value stays the same; only its appearance changes when it meets the condition.

Can you apply conditional formatting to an entire column?

Yes, select the column or enter its column range in Apply to range before adding the rule. A whole-column range can include cells added later, so the rule can keep working as the sheet grows. Use a condition that fits the column’s contents, such as a text match for a status field.

Can you do conditional formatting for a whole row?

Yes, select the full row range and use a custom formula that locks the column being checked. For example, a status in column B can control formatting across columns A through E. Keep the row number free to adjust, so each row checks its own status cell.

Can a conditional-formatting formula refer to another sheet?

Yes, use INDIRECT for a reference to another sheet; ordinary custom formulas can refer to cells on the same sheet. INDIRECT lets the formula build a reference from text. Check the sheet name and cell address in that text, since a typo can keep the condition from matching.

How do I highlight duplicates in Google Sheets?

Apply =COUNTIF($A$1:$A$100,A1)>1 to A1:A100 to highlight values that appear more than once. The formula counts each value in the full range and flags any count above one. It marks every repeated copy, not just the later entry, so decide whether that fits your review process.

About the author

Latest Posts