TechBuzzPro

Conditional Formatting with Formulas in Excel

· 6 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Conditional formatting with formulas lets you highlight cells based on any logic you can write in a formula, going far beyond the built-in presets like "greater than" or "top 10." You can highlight entire rows when one cell meets a condition, flag dates that are overdue, or color cells that contain specific text. This guide walks you through writing a formula-based rule, applying it to the right range, and fixing it when it doesn't work.

What You'll Need

  • Microsoft Excel (2010 or later, including Microsoft 365) or Google Sheets
  • A worksheet with data you want to format
  • Basic familiarity with Excel formulas (like =A1>10 or =AND(B2="Yes",C2<50))

Step-by-Step

  1. Select the range you want to format. This is the area where the formatting will appear. For example, if you have a table from A1 to C20, select A1:C20. If you only want to format column A, select A1:A20. The active cell (the white cell in the selection) matters—your formula will be relative to that cell.
  2. Open the Conditional Formatting menu. In Excel, go to the Home tab, click Conditional Formatting, then choose New Rule. In Google Sheets, go to Format > Conditional formatting.
  3. Choose the formula rule type. In Excel, select Use a formula to determine which cells to format. In Google Sheets, under the "Format cells if" dropdown, select Custom formula is.
  4. Write the formula. This is the core step. The formula should be written relative to the active cell (the first cell in your selection). For example, if you selected A1:C20 and A1 is the active cell, your formula will reference A1. To highlight rows where column B is greater than 100, use =$B1>100. The dollar sign locks the column, but the row number is relative, so it adjusts for each row.
  5. Set the formatting style. Click the Format button (Excel) or choose a fill color (Google Sheets) to define what the cells will look like when the condition is true—for example, a yellow fill or bold red text.
  6. Apply the rule. Click OK (Excel) or Done (Google Sheets). The formatting will apply immediately to all cells in the range where the formula returns TRUE.
  7. Test and adjust. If the formatting doesn't appear where expected, go back to the rule and check the range and formula. You can edit a rule by going to Conditional Formatting > Manage Rules (Excel) or Format > Conditional formatting (Google Sheets).

Common Mistakes

  • Forgetting the dollar sign ($) for absolute references. If you want to lock a column or row, you must include the dollar sign. Without it, the reference shifts relative to each cell, which often leads to unexpected results.
  • Using the wrong active cell. The formula is relative to the active cell, not the top-left of the selection. If you select A1:C20 but the active cell is B2, your formula should reference B2, not A1.
  • Applying the rule to the entire column when you only need a range. This can slow down your workbook and cause formatting to appear in empty cells.
  • Using a formula that returns a number instead of TRUE/FALSE. Conditional formatting expects a logical value. If your formula returns 1 or 0, it may still work in Excel (1 is TRUE, 0 is FALSE), but it's safer to use a comparison like =A1>10.

Tips

  • Use the active cell as your anchor. Always write the formula as if you're writing it for the active cell. This makes it easier to predict how it will behave when applied to the whole range.
  • Test your formula in a regular cell first. Before creating the rule, type the formula in a cell outside your data (e.g., in D1) and copy it down. If it returns TRUE/FALSE correctly, it will work in conditional formatting.
  • Use named ranges for readability. If you have a complex formula, define a named range (e.g., Sales) and reference it as =Sales>100. This makes the rule easier to understand later.
  • Combine conditions with AND/OR. For example, =AND($A1="Yes", $B1>50) highlights only rows where both conditions are true.
  • Use the Stop If True checkbox. In Excel, when you have multiple rules, enabling "Stop If True" prevents lower-priority rules from overriding the formatting.

Troubleshooting

The formatting doesn't appear at all. Check the formula for errors. Go to a blank cell, enter the formula as it applies to the first cell in your range, and see if it returns TRUE. If it returns FALSE, the formula logic is wrong. Also, ensure the range you selected is correct—if you selected A1:A10 but the formula references B1, it will only format when B1 is true, which might be fine, but make sure that's what you intended.

The formatting appears on the wrong cells. This usually means the active cell was not the one you expected. For example, if you selected A1:C20 and the active cell was B2, your formula should reference B2, not A1. Delete the rule and re-create it, making sure the active cell is the top-left cell of your selection.

The formula works in a cell but not in conditional formatting. In Excel, conditional formatting formulas cannot reference other worksheets directly (unless you use a named range). If you're referencing another sheet, create a named range that points to the other sheet's cells. Also, ensure you haven't accidentally used relative references where absolute ones are needed.

The rule disappears or is ignored. In Excel, check the order of rules in Manage Rules. If a higher-priority rule already formats the cell and has "Stop If True" enabled, your rule won't apply. Move your rule up or uncheck "Stop If True". In Google Sheets, ensure the rule is not below another rule that covers the same range with a higher priority.

Frequently Asked Questions

Can I use conditional formatting to highlight an entire row based on a cell in that row? Yes. Select the entire range of rows (e.g., A1:C20), and use a formula with a mixed reference like =$B1>100. The dollar sign before B locks the column, but the row number (1) is relative, so it will check each row's B cell.

How do I highlight cells that contain specific text? Use the COUNTIF or SEARCH function in your formula. For example, =COUNTIF(A1,"*pending*")>0 will highlight cells containing the word "pending" (case-insensitive in Excel). In Google Sheets, you can also use =REGEXMATCH(A1,"pending").

Can I use a formula that references another sheet? In Excel, you cannot directly reference another sheet in a conditional formatting formula. Instead, define a named range on the other sheet (e.g., OtherData) and use that in your formula, like =A1>OtherData. In Google Sheets, you can reference another sheet directly with =A1>Sheet2!A1.

Why does my formula work in a cell but not in conditional formatting? The most common reason is that the formula is not written relative to the active cell. For example, if you selected A1:A10 and the active cell is A1, but you wrote =B1>10, it will check B1 for A1, B2 for A2, etc. If you intended to check the same cell, you need to lock the column with a dollar sign: =$A1>10.

Can I apply multiple conditions to the same range? Yes, you can create multiple rules. Each rule can have its own formula and formatting. In Excel, manage them under Conditional Formatting > Manage Rules. In Google Sheets, you can add multiple rules in the conditional formatting pane. Remember that the order matters—rules higher in the list take precedence.

Is there a limit to how many conditional formatting rules I can have? Excel has a limit of about 64,000 rules per worksheet, but practical performance degrades much earlier. Google Sheets has a limit of 20 rules per sheet (as of 2025). If you need more, consider using a formula that combines multiple conditions with OR or AND.