简体   繁体   English

根据月份和年份查找单元格的值

[英]Find value of a cell according to month and year

I'm sorry in advance if I'm not clear for you.如果我不清楚你,我很抱歉。

I have for example:我有例如:

Figure 1 :

| A        |       B  |
|01/05/2019|     500  |
|01/07/2020|  -100000 |
|01/12/2020|    7633  |

And

Figure 2 :

|     A    |   B       |
|01/05/2019|  -0.3521  |
|01/07/2020|    0.455  |
|01/12/2020|       0   |

I would like to include in the formulas in column B of Figure 1, the value associated with the month and year in relation to column A in figure 2 (found with the date in column A figure 1), bearing in mind that the days are different.我想在图 1 的 B 列的公式中包含与图 2 中的 A 列相关的月份和年份的值(在图 1 的 A 列中找到日期),记住天是不同的。

Thank you.谢谢你。

I would advise you to use a helper column, containing unique information on the month and the year.我建议您使用帮助列,其中包含有关月份和年份的独特信息。 Question is, how will you do this?问题是,你将如何做到这一点? I propose following formula:我提出以下公式:

Helper(date) = 12*Year(date) + Month(date)

Where Year() and Month() are the basic Excel function for retrieving the year number and the month number of the date.其中Year()Month()是基本的 Excel function 用于检索日期的年份和月份。 Using this approach, you can then use the VLookup() function for finding the column you are looking for, something like:使用这种方法,您可以使用 VLookup VLookup() function 来查找您要查找的列,例如:

Figure1:
========

Helper |          A |       B  |
 24233 | 01/05/2019 |     500  |
 24247 | 01/07/2020 |  -100000 |
 24252 | 01/12/2020 |    7633  |

Figure2: (with some modification, I used the second day of the month to clarify 
========  the correctness of the provided formula)

Helper |          A |       B  |
 24233 | 02/05/2019 |  -0.3521 |
 24247 | 02/07/2020 |    0.455 |
 24252 | 02/12/2020 |       0  |

As you can see, a simple VLookup() can be used for searching for the values 24233, 24247, 24252, ...如您所见,一个简单的VLookup()可用于搜索值 24233、24247、24252...

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

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