简体   繁体   English

Excel:检查所有列的值是否不同

[英]Excel: check all columns have a different value

I would like to know how to compare for every row that their (numeric) columns have different values or all of them are equal, and get the result (either a boolean or a 0/1) in another column. 我想知道如何比较它们的(数字)列具有不同值或它们都相等的每一行,并在另一列中获取结果(布尔值或0/1)。 Something like: 就像是:

      colA colB colC   Result
row1  12   12   45     false
row2  67   67   67     true

How could I write this formula concisely in Microsoft Excel? 如何在Microsoft Excel中简洁地编写此公式? Note that the number of columns may vary and at least I have about 30 columns, so I don't want to name the columns in the formula, but write something like a for 请注意,列数可能会有所不同,至少我大约有30列,所以我不想在公式中命名这些列,而是写一个for

Thank you. 谢谢。

If you want to test only numbers, what about? 如果您只想测试数字,那该怎么办?

=MIN(B1:B30)=MAX(B1:B30)

(if your range goes from 1 to 30) (如果您的范围从1到30)

for doesn't exist in Excel formula, the best way to deal with a for loop would be to use array formulas but this is not appropriated here. for在Excel公式中不存在,处理for loop的最佳方法是使用数组公式,但这在此处不适用。

what you may look for is a dynamic range but i can't see a way to implement it easily in your case 您可能要寻找的是动态范围,但我看不到一种可以轻松实现的方法

[EDIT] new formula thanks to Excelll's comment [Excel]感谢Excelll的评论

=AND(MIN(B1:B30)=MAX(B1:B30),COUNTBLANK(B1:B30)=0)

If blank cells within a row are not an issue, @JMax offers a clever solution. 如果一行中的空白单元格不是问题,则@JMax提供了一个聪明的解决方案。 However, if you want a blank cell to return "FALSE", you can use the following array formula: 但是,如果希望空白单元格返回“ FALSE”,则可以使用以下数组公式:

=AND(EXACT(A1,B1:C1))

Enter this as an array formula by pressing Ctrl+Shift+Enter. 通过按Ctrl + Shift + Enter将此输入为数组公式。

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

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