简体   繁体   English

我如何将“查找值”设置为VLOOKUP的日期范围?

[英]How Might I set the Lookup Value to a date range for VLOOKUP?

在此处输入图片说明

Hi, I am trying to obtain the value of X,Y and Z by matching the tender closing date in cell G2 with vlookup. 嗨,我试图通过将单元格G2中的投标截止日期与vlookup匹配来获取X,Y和Z的值。

However, I am truly lost because it returned #n/a. 但是,我真的迷路了,因为它返回了#n / a。

Anybody knows what could be done? 有人知道该怎么办吗?

You cannot use VLOOKUP to match columns to the left, you could however use INDEX. 您不能使用VLOOKUP来匹配左侧的列,但是可以使用INDEX。 With t he example you put in the question enter in cell G3: 以这个例子为例,您在输入单元格G3中输入问题:

=INDEX(A3:A10,MATCH(G2,E3:E10,0))

Then you should get the 'x' value relating to a tender that ended on the date entered in cell G2. 然后,您应该获得与在单元格G2中输入的日期结束的投标有关的“ x”值。 You can then replicate changing the first range in INDEX to columns B and C for the respective y and z values. 然后,您可以将分别将y和z值的INDEX中的第一个范围更改为B和C列。

Bear in mind that INDEX is the same as VLOOKUP in that it will only return the first value, if two tenders finished on the same day it will only return the first it comes across, if you have more than one maybe SUMIF would work better, maybe along side COUNTIF to show how many there were. 请记住,INDEX与VLOOKUP相同,因为它只会返回第一个值,如果在同一天完成了两次招标,则只会返回遇到的第一个投标,如果您有多个投标,SUMIF可能会更好,也许沿着COUNTIF来显示有多少。

EDIT - Further Request for Multiple Columns 编辑-多列的进一步请求

If you want to match the start AND end date you need to use an array formula as below, where the start date you are looking for is in cell G2 asd the end date in cell G3: 如果要匹配开始和结束日期,则需要使用以下数组公式,其中要查找的开始日期在单元格G2中,而结束日期在单元格G3中:

=INDEX(A3:A10,MATCH(1,(G2=D3:D10)*(G3=E3:E10),0))

NOTE This is an array formula so when you have typed the formula you need to press Ctrl + Shift + Enter, not just enter . 注意这是一个数组公式,因此在键入公式后,您需要按Ctrl + Shift + Enter,而不仅仅是按

With this method it is checking two criteria for true/ false (1 and 0 respectively) so it checks each row and if columns D and E match your criteria it does 1*1 and matches the criteria of 1 that you entered. 使用此方法,它会检查两个条件是否为true(分别为1和0),因此它会检查每一行,如果D和E列与您的条件匹配,它将进行1 * 1并与您输入的1匹配。 Any other combination would equal 0, eg if column D matched but E didn't then 1*0 = 0, if neither matched then 0*0 = 0. 其他任何组合都将等于0,例如,如果D列匹配但E则1 * 0 = 0,如果两个都不匹配,则0 * 0 = 0。

Using this you can then extend your lookup, changing the * to a + would return the first row where EITHER column matched the criteria: 然后,您可以使用它扩展查询,将*更改为+将返回第一行,其中EITHER列符合条件:

=INDEX(A3:A10,MATCH(1,(G2=D3:D10)+(G3=E3:E10),0))

You can add further columns in to the criteria using the the same method, I'm not sure what the limit is. 您可以使用相同的方法将更多列添加到条件中,我不确定限制是多少。

I understand that you aren't matching the date in G2 exactly , you simply need to get the range in which it fits. 据我所知,你是不完全匹配G2的日期,你只需要得到它适合的范围内。 To do that and return the correct "x", "y" or "z" value you can use LOOKUP , eg to get "x" value 为此,您可以使用LOOKUP返回正确的“ x”,“ y”或“ z”值,例如,获取“ x”值

=LOOKUP(G2,D3:D10,A3:A10)

That will give you 96.50 for your example data 这将为您的示例数据提供96.50

change the A3:A10 range to B3:B10 or C3:C10 for "y" and "z" values respectively 将“ y”和“ z”值的A3:A10范围分别更改为B3:B10C3:C10

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

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