查找失败安全答案 - excel 公式我没有得到

lookup fail safe answer - excel formula I don't get

this thread : Find last non-zero cell's column reference in an UNORDERED range of values 上,我找到了两个解决问题的方法。但我无法理解他们的工作方式。我确定它在网上某处有记录,但找不到关键字。

=LOOKUP(2,1/(A1:L1<>0),COLUMN(A1:L1))

我应该使用什么关键字来查找关于数组 A1:L1<>0 布尔运算符 result/mechanism 的文档?

用作数组公式 (Ctrl+Shift+Enter) Excel 愉快地计算一个单元格 = A1:L1<>0 作为 = A1<>0。它 returns 一个布尔值(True=1,False=0)。假设稍后反转布尔值,结果数组应该是一系列 1#DIV/0,但 LOOKUP() 搜索 2,如 lookup_value,似乎找到了。

另外还有一个做同样事情的,但是我不会用因为我对数组公式没有信心{=MAX(IF(yourrange=0,0,COLUMN(yourrange)))}

这个答案是从这里摘录的,所以实际上所有的学分都归作者所有:

Excel Formula To Get LAST Non-Zero Value in Row and Return Column Header

这是有效的,因为 1/(E2:CO2<>0) 部分 returns 单元格不为零的 1 数组……或 #DIV/0! 错误所在的位置。 LOOKUP 然后 不会在该数组中找到 2,因此它与最后一个 1 匹配,即具有 non-zero 值的最后一列......然后它 returns 来自 header 行的对应值。

I post it because the question can be marked as duplicate because the answer is not on SO.

更新:我想添加一些额外的信息,基于 Office 支持:

LOOKUP Function

并以此为例this question on SO

根据此来源:

If the LOOKUP function can't find the lookup_value, the function matches the largest value in lookup_vector that is less than or equal to lookup_value.

当你执行 1/(E2:CO2<>0) 部分时 returns 数组 (lookup_vector) 的单元格不为零的 1 ......或 #DIV/0!, 所以我们得到一个这样的数组:

#DIV/0!;#DIV/0!;#DIV/0!;1;1;1;1;1;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!

所以 LOOKUP 从左到右检查数组中的每个值。如果没有找到,就取最大的,也就是1。

但是因为 1 出现在数组中的很多位置,并且最后检查的 1 在第 8 个位置,所以公式然后转到由 COLUMN(A1:L1) (result_vector) 创建的数组这是什么像这样:

1;2;3;4;5;6;7;8;9;10;11;12

它检查第 8 个位置的值,它包含值 8,然后公式 returns 数字 8。

希望这能带来一些启发。