Multiple IF AND statements excel

excel

Solution

Consider that you have multiple "tests", e.g.,

- If E2 = 'in play' and F2 = 'closed', output 3

- If E2 = 'in play' and F2 = 'suspended', output 2

- Etc.

What you really need to do is put successive tests in the `False` argument. You're presently trying to separate each test by a comma, and that won't work.

Your first three tests can all be joined in one expression like:

`=IF(E2="In Play",IF(F2="Closed",3,IF(F2="suspended",2,IF(F2="Null",1))))`

Remembering that each successive test needs to be the nested FALSE argument of the preceding test, you can do this:

`=IF(E2="In Play",IF(F2="Closed",3,IF(F2="suspended",2,IF(F2="Null",1))),IF(AND(E2="Pre-Play",F2="Null"),-1,IF(AND(E2="completed",F2="closed"),2,IF(AND(E2="suspended",F2="Null"),3,-2))))`

Problem

I need to write an "if" statement in Excel based on text in two different cells. ``` If E2 ='in play' and F2 ='closed' output 3 If E2= 'in play' and F2 ='suspended' output 2 If E2 ='In Play' and F2 ='Null' output 1 If E2 ='Pre-Play' and F2 ='Null' output -1 If E2 ='Completed' and F2 ='Closed' output 2 If E2 ='Suspended' and F2 ='Null' output 3 If anything else output -2 ``` where Null is no value in the cell I was trying to do this with the code below but I can't seem to get two or more IF AND statements working together. How can I solve this problem? ``` =IF(AND(E2="In Play",F2="Closed"),3, -2), IF(AND(E2="In Play",F2=" Suspended"),3,-2) ```

Original source