How to Automatically Format Excel Codes with Colors using Conditional Formatting
Question details
The user wants to automatically apply specific fill colors to worksheet cells when specific text codes, such as PM, are entered.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Data entry and spreadsheet organization where visual color-coding is required based on specific text input.
- Observed behavior
- Cells need to automatically change background or text color immediately after a specified code is typed into them.
Ensure you know exactly which text codes you will use and the specific colors you want to assign to each code. It is best to highlight the entire range of cells you plan to apply these rules to before starting the process.
Use Conditional Formatting with a Text Rule
This is the simplest method for applying a specific color to a cell when it contains a single text code like 'PM'.
By using the built-in Highlight Cells Rules, you can quickly instruct your spreadsheet to look for specific text strings and apply a background color or font color automatically.
Click and drag to highlight the range of cells where you want the color formatting to apply when you type your codes.
Navigate to the 'Home' tab on the ribbon, click on the 'Conditional Formatting' button, and hover over 'Highlight Cells Rules'.
Choose 'Equal To' or 'Text that Contains'. In the dialog box that appears, type your specific text code (for example, type PM).
Select a pre-defined color combination from the drop-down menu, or click 'Custom Format' to choose a specific fill color, then click 'OK'.

Apply Formula-Based Rules for Multiple Text Codes
This method is best used when you have multiple different codes that each require a distinct color in the same column or range.
Color Code Your Data Easily in WPS Spreadsheet
WPS Spreadsheet offers powerful and intuitive Conditional Formatting tools that let you easily color-code your data based on specific text or numeric criteria.
- 1. Open your workbook: Launch WPS Spreadsheet and open the document where you want to apply your color codes.
- 2. Select the cells: Click and drag to highlight the specific cells, rows, or columns you want to format.
- 3. Access Conditional Formatting: Go to the Home tab and click on the 'Conditional Formatting' icon.
- 4. Set the text rule: Select 'Highlight Cells Rules' > 'Text that Contains', type your code, pick a custom color, and hit 'OK'.

Frequently Asked Questions
Can I apply conditional formatting to an entire row based on one cell's text code?
Yes. Select the entire row or dataset, go to Conditional Formatting > New Rule, choose 'Use a formula to determine which cells to format', and enter a formula with an absolute column reference, such as =$A1="PM". Then apply your desired fill color format.
How do I remove conditional formatting rules from my cells?
To clear formatting, select the affected cells, go to 'Home' > 'Conditional Formatting' > 'Clear Rules', and choose either 'Clear Rules from Selected Cells' or 'Clear Rules from Entire Sheet'.
Is there a limit to how many conditional formatting rules I can add for different text codes?
While modern spreadsheet software supports up to 64 conditional formatting rules per cell, having too many rules can slow down workbook performance. For more than 10-15 distinct codes, consider using VBA or setting up a dynamic Lookup table instead.
Why isn't my conditional formatting color updating automatically when I type a code?
Ensure that your workbook calculation options are set to 'Automatic' rather than 'Manual'. Go to the Formulas tab on your ribbon and check your Calculation Options. Additionally, check if there are leading or trailing spaces in the cell you are typing into, which might make it mismatch the exact text rule.




