Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Conditional Formatting Based on Another Column

· 6 min read · Home Tech

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

To apply conditional formatting based on another column in Excel, you must use a formula-based rule rather than the standard preset highlights. This allows you to tell Excel to look at a specific cell in Column B to decide whether to change the color of a cell in Column A. This technique is essential for creating dynamic dashboards, tracking project deadlines, or highlighting entire rows based on a status update (such as marking a whole row green when a status column says "Complete").

What You'll Need

  • A dataset organized in columns and rows.
  • A clear understanding of which column contains the "trigger" value (the criteria) and which column or range needs to be formatted.
  • Microsoft Excel (this method works across most modern versions, including Office 365, Excel 2021, 2019, and 2016).

Step-by-Step

  1. Select the Target Range: Highlight the cells you want to change color. If you want only one column to change, select that column. If you want the entire row to change color based on one cell, highlight the entire data table (excluding headers). Note that the cell you select first (the active cell) is the reference point for the formula you will write.
  2. Open Conditional Formatting: Navigate to the Home tab on the top ribbon. In the Styles group, click on Conditional Formatting.
  3. Create a New Rule: From the dropdown menu, select New Rule.... This opens a dialog box with several rule types.
  4. Select the Formula Option: In the "Select a Rule Type" section, click the last option: Use a formula to determine which cells to format. This opens a text box where you can enter your custom logic.
  5. Write the Formula: In the "Format values where this formula is true" box, enter your formula. For example, if you want to highlight cells in Column A based on whether Column B contains the word "Urgent", you would type =$B2="Urgent".
    • The = sign starts the formula.
    • The $ symbol before the B is critical; it locks the reference to Column B so that every cell in the row looks at Column B, even if the formatting is applied to Columns A, C, and D.
    • The 2 refers to the first row of your selected data range. If your data starts on row 5, use $B5.
  6. Set the Format: Click the Format... button. A new window will appear allowing you to choose the formatting. Navigate to the Fill tab to pick a background color, or the Font tab to change text color or make it bold. Once you have selected your preferred style, click OK.
  7. Apply and Confirm: Click OK again in the New Formatting Rule dialog box. Your selected range should now instantly change color based on the values in the reference column.

Common Mistakes

The most frequent error is forgetting the absolute reference symbol (the dollar sign) before the column letter. If you write =B2="Complete" instead of =$B2="Complete", Excel uses relative referencing. This means as the formatting moves from Column A to Column B, the formula shifts its gaze from Column B to Column C, causing the highlighting to appear in the wrong place or not at all.

Another common mistake is a mismatch between the formula row and the selection range. If you have highlighted your data starting from row 2 down to row 100, but your formula refers to $B1, the formatting will be shifted by one row. The formula must always point to the very first row of the range you have highlighted.

Users also frequently forget that text strings in formulas must be enclosed in double quotation marks. Writing =$B2=Urgent will result in an error or no formatting because Excel looks for a named range called "Urgent" rather than the word itself. Always use ="Urgent".

Lastly, overlapping rules can cause confusion. If you have multiple rules applied to the same range, Excel processes them in the order they appear in the manager. If a cell meets the criteria for two different rules, the rule at the top of the list takes priority unless "Stop If True" is checked.

Tips

To highlight an entire row based on a value, simply select the entire data table before following the steps above. Because you locked the column with the $ sign (e.g., =$B2="Yes"), every cell in that row will check the value of column B and react accordingly.

You can use mathematical operators for numeric triggers. For example, to highlight rows where a budget in Column C is over 1000, use =$C2>1000. You can also combine multiple conditions using the AND or OR functions. For instance, =AND($B2="Open", $C2>100) will only highlight the cell if both conditions are met.

For more flexibility, instead of typing the text directly into the formula, point the formula to a cell. For example, =$B2=$Z$1. Now, whatever you type into cell Z1 will automatically update the highlighting across your entire sheet without you having to edit the conditional formatting rule.

Use the Manage Rules option under the Conditional Formatting menu to see a bird's-eye view of all rules applied to your sheet. This is the fastest way to fix a range error or change a color without starting from scratch.

Troubleshooting

If the formatting is not appearing, first check your quotation marks. Ensure you are using standard straight quotes (") and not "curly" or smart quotes often produced by word processors, as Excel does not recognize them.

If the highlighting is shifted (e.g., row 3 is highlighted based on the value in row 2), check your range selection. Go to Conditional Formatting > Manage Rules. Look at the "Applies to" range and compare it to the row number in your formula. If the range starts at $A$2:$G$100, your formula must use row 2 (e.g., =$B2).

If the formatting is inconsistent across the row, verify the dollar sign placement. Ensure the $ is specifically in front of the column letter ($B2) and not the row number (B$2) or both ($B$2). Locking the row ($B$2) will make every single cell in your entire table look only at that one specific cell, rather than checking its own row.

If nothing happens and there are no errors, ensure that the data in your reference column exactly matches your formula. A trailing space (e.g., "Complete " instead of "Complete") will cause the formula to return FALSE. You can use the TRIM function within your formula to ignore accidental spaces: =TRIM($B2)="Complete".

Frequently Asked Questions

Can I use this to highlight cells based on a date?

Yes. You can use formulas like =$B2<TODAY() to highlight rows where a date in Column B has already passed, which is very useful for tracking overdue tasks.

Does this work with tables formatted as "Official Excel Tables"?

Yes, it works with official tables, but be aware that Excel may automatically expand the conditional formatting range as you add new rows to the table, which is a significant advantage over standard ranges.

Can I highlight a cell based on a value in a different worksheet?

In older versions of Excel, you cannot refer to other sheets directly in conditional formatting. However, you can bypass this by creating a Named Range for the cell on the other sheet and then referencing that name in your formula.

Will this slow down my workbook?

Conditional formatting is "volatile," meaning it recalculates frequently. If you apply complex formulas to tens of thousands of rows, you may notice a lag in performance. For massive datasets, consider using a helper column with a simple IF statement and formatting based on that helper column.

How do I remove the formatting?

Select the affected cells, go to Conditional Formatting > Clear Rules, and choose either "Clear Rules from Selected Cells" or "Clear Rules from Entire Sheet."