简体   繁体   English

Excel:返回具有一个查找值但在另一张纸上的多个项目

[英]Excel: Return Multiple Items with One Lookup Value but on a different sheet

My formula works, but only if its in the same page, and along the same rows 我的公式有效,但前提是该公式位于同一页面的同一行中

Formula: 式:

=(INDEX($C$1:$D$4,SMALL(IF($C$1:$C$4=$F$2,ROW($C$1:$C$4)),COLUMNS(D1:D4)),2))

Note: Column G has the formula, what it does it look for value in F2 (which is 1.2) within the columns of C & D, and extracts the respective data in column D. So in this case, it would extract the data in column G. 注意: G列具有公式,它在C&D列中查找F2中的值(即1.2),然后提取D列中的相应数据。因此,在这种情况下,它将在G栏。

Question: Now what do I do if I want this to occur from different sheets, or even different workbooks? 问题:现在,如果我希望这种情况发生在不同的工作表甚至不同的工作簿中,该怎么办? I need to do this exact same thing, extract the data that is in column c and d (which is on a different workbook) to my workbook. 我需要做同样的事情,将c和d列(在不同的工作簿中)中的数据提取到我的工作簿中。

Every time I try, I get a value error. 每次尝试时,都会出现值错误。

Bonus: I'm also trying to get the date that is closest to today's date, I have this formula here: 奖励:我也在尝试获取最接近今天日期的日期,这里有这个公式:

=IF(COUNT(G2:G5)>0,INDEX(G2:G5,MATCH(MIN(ABS(G2:G5-$D10)),ABS(G2:G5-$D10),0)),"")

Where D10 is just equal to =TODAY() and this entire formula works by pressing ctrl+shift+enter D10等于=TODAY() ,整个公式通过按ctrl + shift + enter起作用

If you can also include this into the formula so that it just spits out the closest date in G2 rather than spit out all the dates. 如果您还可以将其包括在公式中,以便它只吐出G2中最接近的日期,而不吐出所有日期。 But it is not necessary, just helps a lot. 但这不是必需的,只是很有帮助。

For your "Closest to today problem", I was trying to spread the difference of the date or a comparison of the date just like in your example. 对于您的“最接近今天的问题”,我试图像您的示例中那样分配日期差或日期比较。 This is just not working out. 这只是没有解决。 I solved the problem by adding another column. 我通过添加另一列解决了这个问题。 I do not know if this is a valid option for you or not, but here is what I have. 我不知道这是否对您有效,但这就是我所拥有的。 Assuming H is available or you can insert a new column H. use this dragged down for each row - in your exampl 2 thorugh 5. 假设H可用或您可以插入新列H。请在每行5中将其向下拖动使用-在示例2中。

=ABS(D$10-G2)

Then add this in H10 or wherever you see fit 然后将其添加到H10或您认为合适的任何位置

=D10-(MIN(H2:H5))

Here is an excel-ish example 这是一个优秀的例子

                    5/12/2014   =ABS(D$10-G2)
                    5/13/2015   =ABS(D$10-G3)
                    5/14/2014   =ABS(D$10-G4)
                    5/15/2014   =ABS(D$10-G5)




        6/6/2016            =D10-(MIN(H2:H5))   

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

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