Excel中的三个IF语句

时间:2016-08-16 14:31:25

标签: excel function if-statement

我需要编写IF函数来执行以下操作。我有两个参数:

A: x
B: x

If "A1" is "x" and "B1" is "" -> "1"
If "B1" is "x" and "A1" is "" -> "2"
If "A1" and "B1" is "x" -> "3"
If in "A1" and "B1 is nothing -> "4"

我提出了这个功能,但它没有正常工作:

=IF(A1="x";"1";IF(B1="x";"2";IF(A1="x";"3";"4")))

3 个答案:

答案 0 :(得分:3)

这是否有效:=IF(AND(A1="x",B1="x"),"3",IF(AND(A1="x",B1=""),"1",IF(AND(A1="",B1="x"),"2","4")))

答案 1 :(得分:3)

试试这个:

=IF(AND(A1="x",B1=""),1,IF(AND(B1="x",A1=""),2,IF(AND(A1="x",B1="x"),3,4)))
如果没有任何声明的输入,

EDIT 会显示空白:

=IF(AND(A1="x",B1=""),1,IF(AND(B1="x",A1=""),2,IF(AND(A1="x",B1="x"),3,IF(AND(A1="",B1=""),4,""))))

答案 2 :(得分:3)

=1+MOD(LEN(A1&B1&B1)+3,4)