A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Use either data validation for an error message, or conditional formatting for a color highlight.
For the exact rule described:
- A1 = 99
- A2 must equal
JC
A good way to highlight A2 when it is wrong is conditional formatting.
- Select A2.
- Go to Home > Conditional Formatting > New Rule.
- Choose Use a formula to determine which cells to format.
- Enter this formula:
=AND($A$1=99,$A$2<>"JC")
- Click Format.
- Choose a fill color.
- Click OK.
Result:
- If A1 contains 99 and A2 is anything other than
JC, cell A2 is highlighted. - If A1 is not 99, the rule does not apply.
If a blank A2 should also be treated as invalid when A1 is 99, the same formula already does that.
If a pop-up style warning is preferred instead of just color, use Data Validation on A2 with a custom formula:
=OR($A$1<>99,$A$2="JC")
That allows either:
- A1 is not 99, or
- A2 is JC
If A1 is 99 and A2 is not JC, Excel can show an error alert.