多嵌套If语句 – 或者不工作
在Excel中使用嵌套的If语句我一直试图使用以下标准获取结果:
在100和75000伏特之内,但应该接受11; 22; 25; 26; 30; 33; 66,因为他们将在千伏
源数据是在一个表中的Transformers
和公式也返回两个其他表MASTER
和META
。
我已经试过了以下所有的IF/AND/OR
变体,但是我之前很less使用嵌套的if语句,所以不在逻辑之内。 任何帮助感激地收到! 谢谢
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2"), IF(OR(Transformers!T2>=110, Transformers!T2<=75000) OR(Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3"))
谢谢
看起来你需要一个AND作为你OR的第一个术语。 括号也看起来不正确。 一旦复杂度达到某个阶段,它有时可以帮助用空白的记事本组合公式,像白色的空间来显示逻辑:
=IF(MASTER!N2="Failed Check 1", "Failed Check 1", IF(META!N2="Failed Check 2", "Failed Check 2", IF(OR( AND(Transformers!T2>=110, Transformers!T2<=75000), Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66 ), "Failed Check 3", "Passed Check 3" ) ) )
没有linebreak这是:
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2", IF(OR(AND(Transformers!T2>=110, Transformers!T2<=75000),Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3")))
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2", IF(OR(Transformers!T2>=110, Transformers!T2<=75000, Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3")))
你公式中的一些问题:
- 在第二个
OR
逗号缺失之前,它应该是),OR(
- 第一个
OR
右括号缺失,应该是...=66)),...
-
IF
右括号缺失,你的公式应该结束)))
-
+1你正在寻找100和75000之间的值,这可以用
AND
而不是OR
来完成
另一种方法
为了简化您的公式,您可以将有效的kV值放在一个范围内并引用它; 让我们称之为kVolts
(每个单元一个值,在一行或一列中)
简化公式:
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2"), IF(OR(AND(Transformers!T2>=110, Transformers!T2<=75000),IFERROR(MATCH(Transformers!T2,kVolts,0)>0,FALSE)) ,"Failed Check 3","Passed Check 3")))
基于你的条件,我会build议你实现这个假设你的数据在单元格A1的class轮。
=IF(OR(AND(A1>=100,A1<=75000),A1=11,A1=22,A1=25,A1=26,A1=30,A1=33,A1=66),TRUE,FALSE)
虽然这只返回TRUE或FALSE,它不会告诉你它已经通过了哪个检查。