How to Change Excel Row Background Color Based on Cell Value S or P
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'.

- 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.
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.
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.
Highlight the specific range of cells where you want the background color to change. For example, select cells B9 through F550.
Go to the 'Home' tab on the ribbon, click on 'Conditional Formatting', and select 'New Rule' from the drop-down menu.
In the New Formatting Rule dialog box, select the option 'Use a formula to determine which cells to format'.
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.
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.

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. Open your file in WPS: Launch WPS Spreadsheet and open your workbook.
- 2. Select the target range: Highlight the cells you wish to automatically format, such as B9:F550.
- 3. Apply the conditional rule: Navigate to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format.
- 4. Enter the formula and format: Input =OR($B9="S",$B9="P"), set your background fill to white, and save the rule.

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.




