简体   繁体   English

Excel 间接 function 与匹配

[英]Excel Indirect function with Match

I am currently using the below formula which is returning an error.我目前正在使用返回错误的以下公式。

What I am trying to do is select the entire column in the Price worksheet by using the indirect function and then return a value from that column based on 2 criteria's.我想要做的是 select 使用间接 function 的价格工作表中的整个列,然后根据 2 个标准从该列返回一个值。 I'm not sure where I'm going wrong.我不确定我哪里出错了。 Any help would be much appreciated.任何帮助将非常感激。

=INDEX(INDIRECT("Prices:J2,J2"),MATCH(F5:Prices,B,B,0):MATCH(D5,Prices!A:A,0)) =INDEX(INDIRECT("价格:J2,J2"),MATCH(F5:价格,B,B,0):MATCH(D5,价格!A:A,0))

  • Prices:J2:J2 In cell J2 I have the column I want to reference in the Price worksheet价格:J2:J2在单元格 J2 中,我在价格工作表中有要引用的列

  • MATCH(F5,Prices:B,B,0),MATCH(D5:Prices,A:A,0) I want to get a Price from the column referenced above where 2 conditions match. MATCH(F5,Prices:B,B,0),MATCH(D5:Prices,A:A,0)我想从上面引用的列中获取 2 个条件匹配的价格。

The below code works for me but it is not robust.下面的代码对我有用,但它并不健壮。 I'd like to get the INDIRECT working我想让 INDIRECT 工作

=INDEX(Prices!BO:BO,MATCH(1,(D2=Prices!A:A)*(F2=Prices!$B:$B),0))

See error below:请参阅下面的错误:

错误信息

Thanks!谢谢!

It looks like you are trying to look up the value from F2 in Column B and then return the corresponding entry in Column J. If so then this is the correct syntax:看起来您正在尝试从 B 列中的 F2 中查找值,然后在 J 列中返回相应的条目。如果是这样,那么这是正确的语法:

=INDEX(Prices!J:J,MATCH(F2,Prices!B:B,0),1)

It also works if you add in INDIRECT:如果您添加 INDIRECT,它也可以工作:

=INDEX(INDIRECT("Prices!J:J"),MATCH(F2,Prices!B:B,0),1)

This website is a good reference for using index and match:这个网站是使用索引和匹配的一个很好的参考:

https://exceljet.net/index-and-match https://exceljet.net/index-and-match

Edit: some more relevant info from chat that helped the asker find his solution:编辑:来自聊天的一些更相关的信息,帮助提问者找到了他的解决方案:

To make the "J" Column in the above formula adjustable from Cell F2, concatenate the address like so:要使上述公式中的“J”列可从单元格 F2 调整,请像这样连接地址:

INDIRECT("Prices!"&J2&":"&J2)

So, if you put "C" in Cell J2, then INDIRECT will reference "Prices:C.C" and then INDEX will look up your data from Column C.因此,如果您在单元格 J2 中输入“C”,则 INDIRECT 将引用“价格:C.C”,然后 INDEX 将从 C 列查找您的数据。

As for MATCH syntax, don't do this:至于 MATCH 语法,不要这样做:

=INDEX(INDIRECT("Prices!"&J2&":"&J2),MATCH(1,(F3=Prices!B:B)‌​*(D3=Prices!$A:$A),0‌​))

Instead, concatenate F3 and D3, concatenate Column A and B data into Column A, and then do the MATCH, something like this:相反,连接 F3 和 D3,将 A 列和 B 列数据连接到 A 列,然后执行 MATCH,如下所示:

=INDEX(INDIRECT("Prices!"&J2&":"&J2),MATCH(D3&F3,Prices!A:A​,0‌​))

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

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