简体   繁体   English

Excel:数组公式返回意外结果

[英]Excel: Array formula returning unexpected result

I have the formula: 我有公式:

=IF(C2=$C$1:C2,1,0)

which returns the value 1 (I believe this is correct as C2 will find a match with C2). 它返回值1(我相信这是正确的,因为C2将找到与C2的匹配项)。 My problem is that if I turn this into an array formula 我的问题是,如果我将其转换为数组公式

{=IF(C2=$C$1:C2,1,0)}

this returns a value of 0, however I am not sure why. 这将返回0值,但是我不确定为什么。

Could someone provide an explanation on the different results from each formula? 有人可以解释每个公式的不同结果吗?

In the non-array version, the fact that you are passing an array of cells to the IF function is redundant, since, without array-coercion, the array resolves to just the first cell within that array, ie C1, so effectively the (non-array) construction: 在非数组版本中,将一个单元格数组传递给IF函数这一事实是多余的,因为在没有数组强制的情况下,该数组仅解析为该数组中的第一个单元格,即C1,因此有效地(非数组)构造:

=IF(C2=$C$1:C2,1,0) = IF(C2 = $ C $ 1:C2,1,0)

is identical to simply: 等同于简单地:

=IF(C2=$C$1,1,0) = IF(C2 = $ C $ 1,1,0)

In the array version, a 1 will only be returned if the values in both C1 and C2 are equal to the value in C1 (though of course this is a little redundant in itself, since the value in C1 will always be equal to itself!). 在阵列版本,一个1将仅在C1和C2的值是等于C1返回值(当然这是在本身少许多余的,因为在C1的值将总是等于本身! )。

What exactly are you trying to do with this odd-looking construction? 您到底想用这种奇怪的结构做什么?

Regards 问候

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

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