简体   繁体   English

包含多个选项的if-then语句

[英]If-then statement with multiple options

I have been working on an IF statement where there are multiple answers but I can't seem to get the formula to work. 我一直在处理有多个答案的IF语句,但似乎无法使公式起作用。 The If statement is going to look at two columns of data and should pull back the first NUMBER. If语句将查看两列数据,并应拉回第一个NUMBER。 Sometimes the first column will say "#N/AN/A" in which case the formula should look to the second column and pull that NUMBER. 有时第一列会显示“#N / AN / A”,在这种情况下,公式应查看第二列并拉出NUMBER。 If both columns say "#N/AN/A" then I would like the answer to be "NR". 如果两列都说“#N / AN / A”,那么我希望答案是“ NR”。

In another scenario I will have three columns of data. 在另一种情况下,我将有三列数据。 I would like the formula to pick up the first number in the columns no matter what follows. 我希望无论后面如何公式都会在列中选择第一个数字。 Again, if all three columns say "#N/AN/A" I would like the answer to be "NR". 同样,如果所有三列都说“#N / AN / A”,我希望答案是“ NR”。

I will attach two examples of what I am talking about. 我将附上我所谈论的两个例子。 Here is the formula I have now but I can't seem to get it to work: 这是我现在拥有的公式,但是我似乎无法使它起作用:

=IF(ISBLANK(B3),"",IF(D3="#N/A N/A",$D3,$D4))

Unfortunately, this formula isn't taking into account if D3 is actually a number. 不幸的是,如果D3实际上是一个数字,则该公式未考虑在内。 It also doesn't account for if both D3 and D4 are "#N/AN/A". 它还不考虑D3和D4是否均为“#N / AN / A”。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks, 谢谢,

Here is the example : 这是示例:

例子1

This allows the use of many columns without the need for multiple nested ifs. 这允许使用许多列而无需多个嵌套的if。

It will return the first column that is not #N/AN/A : 它将返回不是#N/AN/A的第一列:

=IFERROR(INDEX(3:3,,AGGREGATE(15,6,COLUMN(D3:E3)/(D3:E3<>"#N/A N/A"),1)),"NR")

So to do more columns simple change both the D3:E3 to the range desired. 因此,要做更多的列,只需将D3:E3都更改为所需范围即可。 The 3:3 should match the row being searched. 3:3应该匹配要搜索的行。

You can check each cell (from left to right) and return the first instance of a numerical value using a combination of IF & ISNUMBER 您可以检查每个单元格(从左到右),并结合使用IFISNUMBER返回数值的第一个实例


Checking 2 Columns 检查2列

=IF(ISNUMBER(D3),D3,IF(ISNUMBER(E3),E3,"NR"))

Checking 3 Columns 检查3列

=IF(ISNUMBER(D3),D3,IF(ISNUMBER(E3),E3,IF(ISNUMBER(F3),F3,"NR")))

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

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