如果,和,或 - 多个条件

时间:2013-04-23 19:10:58

标签: excel excel-formula

有没有人知道如何在excel中创建具有多个条件的IF,OR,AND函数?

我使用以下公式使功能正常工作(只有2个条件正在工作,当我尝试放置附加条件时功能失败);

=IF(OR(AND(B2>3,C2>1000,E2="Yes"),AND(B2>3,C2>500,E2="Yes")),
"5","4")

我需要函数传递5个可能输出中的任何一个,它们如下;

if (B2>=3 and C2>1000 and E2="Yes") = "5"

 or

if (B2>=3 and C2>500 and E2="Yes") = "4"

 or

if (B2>=2 and C2>100 and E2="Yes") = "3"

 or

if (B2<=2 and C2>100 and E2="No") = "2"

 or

if (B2<=1 and C2<100 and E2="No") = "1"

干杯,

约什

2 个答案:

答案 0 :(得分:0)

每当你有这么大的公式时,总是将它分成小部分。

例如

'if (B2>=3 and C2>1000 and E2="Yes") = "5"
=IF(AND(B2>=3,C2>1000,E2="Yes"),5,"")

类似地

'if (B2>=3 and C2>500 and E2="Yes") = "4"
=IF(AND(B2>=3,C2>500,E2="Yes"),4,"")

'if (B2>=2 and C2>100 and E2="Yes") = "3"
=IF(AND(B2>=2,C2>100,E2="Yes"),3,"")

'if (B2<=2 and C2>100 and E2="No") = "2"
=IF(AND(B2<=2,C2>100,E2="No"),2,"")

'if (B2<=1 and C2<100 and E2="No") = "1"
=IF(AND(B2<=1,C2<100,E2="No"),1,"")

现在你所要做的就是将它们结合起来

=IF(AND(B2>=3,C2>1000,E2="Yes"),5,IF(AND(B2>=3,C2>500,E2="Yes"),4,IF(AND(B2>=2,C2>100,E2="Yes"),3,IF(AND(B2<=2,C2>100,E2="No"),2,IF(AND(B2<=1,C2<100,E2="No"),1,"")))))

<强> SCREENSHOT

enter image description here

答案 1 :(得分:0)

我认为您的问题可能是您没有相互排斥的逻辑。例如,如果B2,C2和E2中的值分别等于4,1001和Yes,则前三个表达式可以同时为真。

如果你修复了逻辑,你应该能够有效地嵌套你的函数。

祝你好运!