简体   繁体   English

使用公式引用单元格的行值

[英]Referencing a cell's row value using a formula

Suppose my excel sheet looks like this:假设我的 excel 表如下所示:

Name姓名 Houses房屋 Cars owned拥有的汽车 column D D列
John约翰 3 3 3 3 =A&MAX(30,3) =A&MAX(30,3)
Harry哈利 2 2 4 4 .. ..
Vik维克 5 5 1 1 .. ..
.. .. p p k ķ .. ..
... ... q q n n .. ..

In column D, I want to return the row in column A that corresponds to the larger of the two values in cells B2 and C2.在 D 列中,我想返回 A 列中对应于单元格 B2 和 C2 中两个值中较大者的行。 So in cell D2, I would want to return "Vik" because the larger of the two values in B2 (3) and C2 (3) is 3. And the value in cell A3 is Vik.所以在单元格 D2 中,我想返回“Vik”,因为 B2 (3) 和 C2 (3) 中的两个值中较大的一个是 3。单元格 A3 中的值是 Vik。

So in order to arrive at my result, I would input something like ="A"&MAX(B2,C2) in D2.所以为了得到我的结果,我会在 D2 中输入类似 ="A"&MAX(B2,C2) 的内容。

But suppose my formula was a lot more complex and with different data.但是假设我的公式要复杂得多,并且数据不同。

=IFERROR(ArrayFormula(ADDRESS(MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""),,IF($A$1:$D6=B7,COLUMN($A$1:$D6)),"")),MAX(IF($A$1:$D6=B7,COLUMN($A$1:$D6),"")))),"")

and I wanted the result of the first chunk of the formula (from ADDRESS() onwards)我想要公式的第一块的结果(从 ADDRESS() 开始)

MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),"") (which is 3 , say) to be the row number that is input into MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),"") (例如3 )作为输入的行号

MAX(IF($A$3:$D3=B7,COLUMN($A$1:$D6),"")) for the range inside the IF condition. MAX(IF($A$3:$D3=B7,COLUMN($A$1:$D6),""))用于 IF 条件内的范围。

(notice how $A$1:$D6 changed to $A$3:$D6) (注意 $A$1:$D6 如何更改为 $A$3:$D6)

So, going by the tabular example above, I would simply input MAX(IF("$A$"&MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""):$D6=B7,COLUMN($A$1:$D6),"")) and that should do the trick. Except it doesn't and I get a formula parse error which I cannot resolve.因此,按照上面的表格示例,我只需输入MAX(IF("$A$"&MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""):$D6=B7,COLUMN($A$1:$D6),""))这应该可以解决问题。除非它没有,我得到一个我无法解决的公式解析错误。

Here is the specific excel sheet I'm working on: https://docs.google.com/spreadsheets/d/12U8U7Jp4FscobIvgr4_sADJB_oSdIHrboCk02cxF_u0/edit?usp=sharing这是我正在处理的特定 excel 表: https://docs.google.com/spreadsheets/d/12U8U7Jp4FscobIvgr4_sADJB_oSdIHrboCk02cxFscobIvgr4_sADJB_oSdIHrboCk02cxFsshare=u0

Can anyone see what I'm doing wrong?谁能看到我做错了什么? The solution, I think, should be simple enough but I can't seem to figure it out.我认为解决方案应该足够简单,但我似乎无法弄清楚。

Sorry if it's a bit long but I've been struggling with this for a while now.对不起,如果它有点长,但我已经为此苦苦挣扎了一段时间。

I hope this formula will help我希望这个公式会有所帮助

=ARRAYFORMULA(IFNA(VLOOKUP(QUERY(TRANSPOSE(QUERY(TRANSPOSE(B2:C6);"select "&JOIN(",";"max(Col"&row(B2:C6)-1&")")));"select Col2+1 label Col2+1''");{row(A:A)\A:A};2;False)))

在此处输入图像描述

Solved using the indirect function and ampersand concatenation.使用间接 function 和 & 连接解决。

New function would be: =IFERROR(ArrayFormula(ADDRESS(MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""),,IF($A$1:$D6=B7,COLUMN($A$1:$D6),""))),MAX(IF(INDIRECT("$A$"&(MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""))))):$D6=B7,COLUMN($A$1:$D6),"")))),"")新的 function 将是: =IFERROR(ArrayFormula(ADDRESS(MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""),,IF($A$1:$D6=B7,COLUMN($A$1:$D6),""))),MAX(IF(INDIRECT("$A$"&(MAX(index(IF($A$1:$D6=B7,ROW($A$1:$D6),""))))):$D6=B7,COLUMN($A$1:$D6),"")))),"")

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

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