user3490456
user3490456

Reputation: 19

How do you combine IF, AND and NOT statements in Microsoft excel

I'm trying to compare Column A and Column B with Column C and Column D and display the results in Column E as shown in the table below using the following formula:

Excel Table

=IF(NOT(IF(AND(A2=C2,B2=D2),"Names Correct","Names Not Correct")),AND(NOT(A2=C2),B2=D2),"Car Worng, Driver Correct", "Car Correct, Driver Wrong")

But I get the error when I press enter:

You've Entered too many arguments for this function

Can someone please point out what I'm doing wrong. Thanks.

Eidt: forgot to include table.

Upvotes: 0

Views: 558

Answers (2)

norie
norie

Reputation: 9857

There's no need to use NOT, the required result can be achieved using nested IF statements and the AND function

=IF(AND(A2=C2,B2=D2),"Names Correct",IF(AND(A2=C2,B2<>D2),"Car Correct, Driver Wrong",IF(AND(A2<>C2,B2=D2),"Car Wrong , Driver Correct","Names Not Correct")))

Or formatted a bit better.

=IF(AND(A2=C2,B2=D2),"Names Correct",
 IF(AND(A2=C2,B2<>D2),"Car Correct, Driver Wrong",
 IF(AND(A2<>C2,B2=D2),"Car Wrong , Driver Correct",
  "Names Not Correct")))

Upvotes: 0

DownloadPizza
DownloadPizza

Reputation: 3466

If you indent your code, you'll see that it doesnt really match up.

=IF(
  NOT(
    IF(
      AND(
        A2=C2,
        B2=D2
      ),
      "Names Correct",
      "Names Not Correct"
    )
  ),
  AND(
    NOT(
      A3=C3
    ),
    B3=D3
  ),
  "Car Worng, Driver Correct", 
  "Car Correct, Driver Wrong"
)

You have a IF(NOT, AND, value1, value2) at the top level. I dont know what your goal was, but hopefully this helps you solve it.

Upvotes: 1

Related Questions