vba 确定列范围中是否有任何单元格等于 0,最终结果为 0,否则为 2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19893077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Determine if any cells in a column range equal to 0, final result is 0, or else is 2
提问by Koo SengSeng
Sorry if my title is confusing. I'm new to Logical formula in excel but I need it to achieve something now. I had check the internet for the formula but found it abit confusing and not sure what method i should use.
对不起,如果我的标题令人困惑。我是 excel 逻辑公式的新手,但我现在需要它来实现某些目标。我已经在互联网上查看了公式,但发现它有点令人困惑,并且不确定我应该使用什么方法。
This is my situation: I have an excel consists over 50+ rows. In each row, there are 5 different columns holding a value of either 1 or 0 with one extra column to determine the final value, which is something like below:
这是我的情况:我有一个包含超过 50 行的 excel。在每一行中,有 5 个不同的列保存 1 或 0 的值,还有一个额外的列来确定最终值,如下所示:
A1 = 0, B1 = 1, C1 = 0, D1 = 1, E1 = 1, F1 = (Final Value)
A1 = 0, B1 = 1, C1 = 0, D1 = 1, E1 = 1, F1 = (最终值)
What I need is the logical statement to check if any cells from A1 to E1 consist of 0, then F1 will be equal to 0, else if all cells value is 1, then F1 is equal to 2.
我需要的是逻辑语句来检查从 A1 到 E1 的任何单元格是否由 0 组成,然后 F1 将等于 0,否则如果所有单元格的值都为 1,则 F1 等于 2。
As i said before, there over 50+ rows with the same thing, each line consists of 5 columns with a value of 1 or 0, and finally one extra column that hold the final value of 0 or 2 according to the 5 columns.
正如我之前所说,有超过 50 行相同的内容,每行由 5 列组成,值为 1 或 0,最后还有一列根据 5 列保存最终值为 0 或 2。
Kindly let me know any method i can use to achieve my needs or if there is any better solution to deal with all the rows which are basically the same thing.
请让我知道我可以用来满足我的需求的任何方法,或者是否有更好的解决方案来处理基本上相同的所有行。
Thank you for your time.
感谢您的时间。
回答by Doug Glancy
I like Gary's Student's for cleverness, but for clarity, I like:
我喜欢加里学生的聪明,但为了清楚起见,我喜欢:
=IF(COUNTIF(A1:E1,0)=0,2,0)
回答by Gary's Student
How about something like:
怎么样:
=MIN(A1:E1)*2
=MIN(A1:E1)*2