简体   繁体   English

如果在多个if上值为false时,如何在Excel中为嵌套的if编写公式?

[英]How do I write the formula in Excel for a nested if when value is false on multiple ifs?

I have a nested if that has 我有一个巢,如果有

=IF(A1=10,"you have 10 points","otherwise blank",IF(A1=20,"you have 20 points","otherwise blank",IF(A1=30,"you have 30 points","otherwise blank"))) = IF(A1 = 10,“你有10点”,“否则为空白”,IF(A1 = 20,“你有20点”,“否则为空白”,IF(A1 = 30,“你有30点”, “否则为空白”)))

What I want is that if it finds 10,20 or 30 to give those outputs otherwise don't display any output, but I get an error that say 我想要的是,如果找到10,20或30来提供这些输出,否则不显示任何输出,但是我得到一个错误,说

You've entered too many arguments for this function. 您为此函数输入了太多参数。

Try doing this: 尝试这样做:

=if(A1=10,"you have 10 points",if(A1=20,"you have 20 points",if(A1=30,"you have 30 points","")))

The logic is as following: 逻辑如下:

  1. If A1=10, you have 10 points 如果A1 = 10,您有10分
  2. If not, then if A1=20, you have 20 points 如果不是,那么如果A1 = 20,那么您有20分
  3. If not, then if A1=30, you have 30 points 如果不是,那么如果A1 = 30,那么您有30分
  4. If not, then it means A1 does not equal either 10, 20 or 30, so return blank. 如果不是,则表示A1不等于10、20或30,因此返回空白。

How about: 怎么样:

=If(OR(A1=10,A1=20,A1=30),"You have " & A1 & " points","")

Or: 要么:

=IF(ISNUMBER(MATCH(A1,{10,20,30},0)),"You have " & A1 & " points","")

Your formula should be something like this: 您的公式应如下所示:

=IF(OR(A1=10,A1=20, A1=30), A1, "") = IF(OR(A1 = 10,A1 = 20,A1 = 30),A1,“”)

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

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