Excel:当指定单元格含特定字符串时,如何为部分单元格设填充与字体颜色?
Got it, let's get this sorted for you! The key here is targeting only the cells you care about (columns A and B) and using the right conditional formatting formula to link them to column E's value. Here's a step-by-step breakdown:
Step 1: Select the target range
Click and drag to select all cells in columns A and B that you want to apply formatting to (e.g.,A2:B100if your data goes down to row 100). Don't select the entire row—stick to just the specific columns you need.Step 2: Open Conditional Formatting rules
Head to the "Home" tab, click "Conditional Formatting" → "New Rule".Step 3: Choose the formula-based rule
In the new rule window, select "Use a formula to determine which cells to format".Step 4: Enter the correct formula
Paste or type this formula into the input box:=$E2="departments"
The$before the E is critical—it locks the column reference, so every cell in A/B checks the corresponding row in column E (A2 checks E2, A3 checks E3, etc.). Without the$, the formula would shift columns when applied to A vs B, which breaks the logic.Step 5: Set your desired formatting
Click the "Format" button, then use the "Fill" tab to pick your background color and the "Font" tab to set text color. Hit "OK" once you're happy with the settings.Step 6: Confirm and apply
Click "OK" again in the rule window, and you're done! Now any row where column E contains "departments" will only have its A and B cells formatted—not the entire row.
Your earlier issue with full-row highlighting likely happened because you selected the whole row instead of just A/B, or your formula didn't lock the column reference properly. This method fixes that by targeting exactly the cells you need.
内容的提问来源于stack exchange,提问作者evenyougreg

