Formatting Issues

How to Change Excel Row Background Color Based on Cell Value S or P

Camila MilosovichCamila Milosovich Nov 10, 2026 868 views

Question details

The user wants to automatically change the fill color of a specific range of cells (columns B through F) to white whenever the corresponding cell in column B contains the letter 'S' or 'P'.

How to Change Excel Row Background Color Based on Specific Cell Values
Product
Spreadsheet
Device & OS
not provided
Scenario
Automating cell fill colors across a multi-column row range based on the text value entered into one specific trigger column.
Observed behavior
The user needs a dynamic formatting rule to instantly update the background color of cells B:F from blue to white without having to manually change the cell shading each time an 'S' or 'P' is entered.
Before you start

Identify the exact range of cells you want to apply the background color to (e.g., B9:F550) and determine which column will act as your trigger column.

Solution 1Recommended

Use Conditional Formatting with a Custom OR Formula

Apply a conditional formatting rule using the OR function to check for multiple values, utilizing an absolute column reference so the entire row range changes color based on one column.

To change the color of multiple cells in a row based on a single cell's value, you must use a formula in your conditional formatting rule. By locking the column reference with a dollar sign (e.g., $B9) but leaving the row relative, the formatting will look strictly at column B while naturally adjusting for each new row.

The OR function evaluates whether the target cell contains either 'S' or 'P'. If either condition is met, the format is applied.

1
Select your target data range

Highlight the specific range of cells where you want the background color to change. For example, select cells B9 through F550.

2
Open the Conditional Formatting menu

Go to the 'Home' tab on the ribbon, click on 'Conditional Formatting', and select 'New Rule' from the drop-down menu.

3
Choose to use a formula

In the New Formatting Rule dialog box, select the option 'Use a formula to determine which cells to format'.

4
Enter the logical OR formula

In the formula input box, type exactly: =OR($B9="S",$B9="P"). Ensure the row number (9) matches the first row of your selected range.

5
Set the desired background color

Click the 'Format' button, navigate to the 'Fill' tab, select white (or your preferred color), click 'OK', and then 'OK' again to apply the rule.

Use Conditional Formatting with a Custom OR Formula
Understanding Cell References: The dollar sign in $B9 is crucial. It creates an absolute column reference, meaning the rule always checks column B, even when formatting cells in columns C, D, E, or F of that same row.

Apply Conditional Formatting Easily in WPS Spreadsheet

WPS Spreadsheet fully supports advanced conditional formatting rules, allowing you to quickly format rows based on text values using custom formulas. It is a highly efficient tool for managing large datasets.

  1. 1. Open your file in WPS: Launch WPS Spreadsheet and open your workbook.
  2. 2. Select the target range: Highlight the cells you wish to automatically format, such as B9:F550.
  3. 3. Apply the conditional rule: Navigate to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
  4. 4. Enter the formula and format: Input =OR($B9="S",$B9="P"), set your background fill to white, and save the rule.
Fully compatible with Microsoft Excel conditional formatting rules, including custom formulas.Intuitive graphical interface for easily setting up and managing multiple formatting rules.Free and lightweight alternative for data analysis, business reporting, and spreadsheet styling.Supports complex logical formulas like OR, AND, and IF for sophisticated automated formatting.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my conditional formatting changing the color of the wrong row?

This usually happens when the row number in your formula does not match the topmost row of your selected range. For instance, if you highlight B10:F500 but your formula says =OR($B9="S",$B9="P"), the formatting will be offset by one row. Always align the formula's row number with the start of your selection.

Can I apply this rule to the entire row instead of a specific range?

Yes. Instead of selecting B9:F550, you can select the entire rows (e.g., clicking the row headers from 9 to 550 or selecting A9:XFD550). Just ensure the formula still uses the absolute reference for column B (e.g., $B9).

Is the conditional formatting formula case-sensitive?

No, standard conditional formatting formulas involving text strings in Excel and WPS Spreadsheet are generally case-insensitive. Entering a lowercase 's' or 'p' will still trigger the rule to change the background color.

How do I remove or edit the conditional formatting rule later?

Select any cell within your formatted range, go to the 'Home' tab, click 'Conditional Formatting', and select 'Manage Rules'. From there, you can select your existing rule and choose to edit the formula/color or delete it completely.