Aug 16 2024 12:13 PM
Hello, I am hoping someone know how to help me set up conditional color coding in excel. I am needing certain cells to populate one color if the others cells are filled out wrong and another color if the cells are filled out right.
Example:
If there is a number in cell E and cell H says F1IL and cell J isn't blank and cell P is blank all these cells turn red.
But if there is a number in cell E and cell H says (anything but F1IL) and cell J is blank and cell P has a number then all these cells turn green.
My goal is to have errors pop up when someone doesn't fill out the information correctly, but to also not have anything highlighted if there is no information entered on that line.
Thank you for your help!
Aug 16 2024 01:15 PM
Let's say you want to apply this to rows 2 to 100.
Select E2:E100. E2 should be the active cell in the selection.
On the Home tab of the ribbon, click Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter the formula
=AND($E2<>"", $H2="F1IL", $J2<>"", $P2="")
Click Format...
Activate the Fill tab.
Select red as fill color.
Click OK, then click OK again.
Repeat these steps, but with the formula
=AND($E2<>"", $H2<>"F1IL", $J2="", $P2<>"")
and green as fill color.
With E2:E50 still selected, double-click the Format Painter button in the Clipboard group of the Home tab of the ribbon.
Click on H2, then on H2 and finally on P2.
Then press Esc to turn Format Painter off.
Aug 16 2024 11:32 PM
Aug 19 2024 06:12 AM
Aug 19 2024 07:33 AM
Use $H2<>"F1IL", as shown in the second rule in my previous reply.
Aug 19 2024 08:05 AM
Aug 19 2024 08:48 AM
Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?
Aug 19 2024 09:36 AM
Ok. I have attached a clean workbook. I added the prompts that I am needing a formula for so the cells can format properly.
Aug 19 2024 11:56 AM
Thanks. Select A2:G19 and clear the existing rules.
Then select A2:A19.
Hold down Ctrl and select C2:C19, then E2:E19 and finally G2:G19.
The active cell in the selection should be in row 2 (i.e. A2, C2, E2, or G2 - it does not matter which of these).
Set the fill color to red - this will be the default.
We're going to create only one rule.
On the Home tab of the ribbon, click Conditional Formatting > New Rule...
Select 'Use a formula to determine which cells to format'.
Enter the formula
=AND(OR(AND($A2<>"", $C2<>"F1IL", $E2=""), AND($A2="", $C2="F1IL", $E2<>"")), $G2>0.17)
This formula is a direct translation of the two conditions for cells to be green. In both conditions, G2 (Hours)should be greater than 0.17. In one condition, A2 (Job) should be filled in, C2 (Work Center) should not be F1IL, and G2 (Code) should be blank. In the other condition, these are reversed.
Click Format...
Activate the Fill tab.
Select green as fill color.
Click OK, then click OK again.
See the attached version.
Aug 19 2024 12:41 PM
Aug 19 2024 01:22 PM
As long as the conditions for green are not satisfied, there will be something missing or incorrect, so it's reasonable to color the cells red...
Aug 19 2024 01:39 PM
Aug 19 2024 02:58 PM
You can easily translate the conditions to formulas. For example, red if
job has number and work center is f1il and code is entered and hours are blank or "0"
translates to
=AND($A2<>"", $C2="F1IL", $E2<>"", $G2=0)
Similarly
job has no number and work center is not f1il or blank and code is blank and hours are greater than .17
translates to
=AND($A2="", $C2<>"F1IL", $E2="", $G2>0.17)