简体   繁体   English

嵌套IF(AND(OR语句

[英]Nested IF(AND(OR statement

Here is my current formula 这是我目前的公式

=IF(OM2=0,"No",IF(OM2=4(OR(5,11,12,16,17))*AND(F2="Double"),"Yes",IF(OM2=1(OR(2,3,6,7,8,9,10,13,14,15))*AND(F2="Triple"),"Yes","No")))

I'm trying to get OU to be yes if OM is 4,5,11,12,16,or 17 and F is Double. 如果OM是4,5,11,12,16或17并且F是Double,我试图使OU为yes。
Also, to get OU to be yes if OM is 1,2,3,6,7,8,9,10,13,or 15 and F is Triple. 另外,如果OM为1,2,3,6,7,8,9,10,13或15并且F为Triple,则使OU为yes。

I have checked F2 and it correctly results "Double" or "Triple" accordingly with correct spelling and no extra spaces. 我检查了F2并正确地使用正确的拼写正确地生成了“ Double”或“ Triple”,没有多余的空格。

I am still getting "No" being resulted, see pic below: 我仍然收到“否”的结果,请参见下图: 在此处输入图片说明

Thanks for any help! 谢谢你的帮助!

Try to write OR(OM2 = x, OM2=y, OM2 = z ...) instead of what you wrote. 尝试编写OR(OM2 = x,OM2 = y,OM2 = z ...),而不是您编写的内容。

This should work. 这应该工作。

As the other responders said you should really think about making a lookup tables. 正如其他响应者所说,您应该真正考虑制作查找表。

In addition, if you use Excel 2013 onwards, it is much easier if you convert your normal table into "Excel" table (Ctrl - T will do it). 另外,如果您使用Excel 2013及更高版本,则将普通表转换为“ Excel”表会更加容易(Ctrl-T可以完成此操作)。 Google more about "Excel tables" to learn about their benefits vs traditional tables. Google会更多地介绍“ Excel表格”,以了解它们相对于传统表格的好处。

After that, set up 2 lookup tables, Table 1 and Table 2 (they themselves should also be Excel tables) as in the photo. 之后,设置2张查找表,如照片中的表1和表2(它们本身也应该是Excel表)。

Then your formula will be: 那么您的公式将是:

=OR(SUMPRODUCT(--(Table1[OM]=[@OM]),--(Table1[F]=[@F])),SUMPRODUCT(--(Table2[OM]=[@OM]),--(Table2[F]=[@F])))

When you write up this formula, you can just select the cells in the respective lookup tables, Excel will automatically turn them into table named ranges as you see above. 当您编写此公式时,您只需在相应的查找表中选择单元格,Excel就会自动将它们转换为如上所示的名为范围的表。

Another option would be to use a lookup table to map your value of OM to the expected value of OU . 另一个选择是使用查找表将OM的值映射到OU的期望值。

For example, if you had a sheet named "Lookup" with the following data: 例如,如果您有一个名为“ Lookup”的工作表,其中包含以下数据:

  | A | B
1 | 1 | Triple
2 | 2 | Triple
...   
5 | 5 | Double

Then you could use something like 然后,您可以使用类似

IF(VLOOKUP(OM2,Lookup!$A$1:$B$16,2,FALSE)=OU2,"Yes","No")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM