Verifying data in 2 cells are valid with each other

Scott Grinder 0 Reputation points
2026-09-11T16:45:24.7533333+00:00

We enter data in 2 cells. When you enter data (number) in A1, the data you enter in A2 (alpha-numeric) must be a specific value. For example, if I enter 99 in cell A1, the data entered in A2 MUST be JC. If I enter anything besides JC in A2 when 99 is entered in A1, I'd like to see it highlighted or some type of message show or pop-up. I'd like to see the cell highlight in color as a preference.

Microsoft 365 and Office | Excel | For business | Windows

2 answers

Sort by: Oldest
  1. AI answer

    2026-09-11T16:45:39.47+00:00

    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.

    1. Select A2.
    2. Go to Home > Conditional Formatting > New Rule.
    3. Choose Use a formula to determine which cells to format.
    4. Enter this formula:
    =AND($A$1=99,$A$2<>"JC")
    
    1. Click Format.
    2. Choose a fill color.
    3. 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.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

  2. Chris-D 1,595 Reputation points Independent Advisor
    2026-09-11T17:35:38.8866667+00:00

    Hi Scott,

    I hope you’ve been well.

    Based on your description, you can use Conditional Formatting in Excel to highlight cell A2 when its value does not match the value required by A1.

    For example, if A1 contains 99, and A2 must contain JC, you can try the steps below:

    1. Select cell A2.
    2. Go to Home > Conditional Formatting > New Rule.
    3. User's image
    4. Select Use a formula to determine which cells to format.
    5. Enter the following formula: =AND($A$1=99,$A$2<>"JC")
    6. User's image
    7. Select Format, choose your preferred fill color, and then select OK.

    After the rule is applied, A2 will be highlighted whenever A1 contains 99 and A2 contains anything other than JC.

    If you also want Excel to prevent users from entering an incorrect value and display an error message, you can additionally configure Data Validation for cell A2.

    For references:

    I hope this information is helpful. Should you have any further questions or need additional assistance, please feel free to share them in the comment below. I'm very happy to help.  


    If the answer is helpful, please click 'Yes' and kindly upvote it.

    Note: Please follow the steps in the forum documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.