Multiple IF AND statements excel

前端 未结 4 1030
甜味超标
甜味超标 2020-12-03 21:43

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\'         


        
4条回答
  •  伪装坚强ぢ
    2020-12-03 22:33

    With your ANDs you shouldn't have a FALSE value -2, until right at the end, e.g. with just 2 ANDs

    =IF(AND(E2="In Play",F2="Closed"),3,IF(AND(E2="In Play",F2=" Suspended"),3,-2))

    although it might be better with a combination of nested IFs and ANDs - try like this for the full formula:[Edited - thanks David]

    =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="Pre-play",F2="Null"),3,-2))))

    To avoid a long formula like the above you could create a table with all E2 possibilities in a column like K2:K5 and all F2 possibilities in a row like L1:N1 then fill in the required results in L2:N5 and use this formula

    =INDEX($L$2:$N$5,MATCH(E2,$K$2:$K$5,0),MATCH(F2,$L$1:$N$1,0))

提交回复
热议问题