简体   繁体   English

如何根据 excel 中当前月份的 select 单元格

[英]How to select a cell based on the current month in excel

I'm looking for some excel help.我正在寻找 excel 的帮助。 I am trying to make a total cell that changes the value selected based on what month it currently is.我正在尝试制作一个总单元格,根据当前月份更改所选值。 Basically in the image the left cell indicates the $ amount for that month and that $ amount is in the cells on the right.基本上在图像中,左侧单元格表示该月的 $ 金额,该 $ 金额位于右侧的单元格中。

For example I want the total cell (not shown in the screenshot) to show 15363.21 from March 1 to 31st, and then change to 15388.81 on April 1st.例如,我希望总单元格(未在屏幕截图中显示)从 3 月 1 日到 31 日显示 15363.21,然后在 4 月 1 日更改为 15388.81。

I have done some research but can't get this to work for me.我做了一些研究,但无法让它为我工作。

我的表格

Pretending month is march Pretending month is April假装月份是三月假装月份是四月

It seems like you are asking for a lookup: "find the single cell in Column A that contains the current month and year, then return the corresponding single cell in Column F."您似乎在要求查找:“在 A 列中找到包含当前月份和年份的单个单元格,然后在 F 列中返回相应的单个单元格。”

There are several ways to do this, but assuming your Excel version supports XLOOKUP, the code to place inside your total cell could be:有几种方法可以做到这一点,但假设您的 Excel 版本支持 XLOOKUP,则放置在总单元格中的代码可以是:

=XLOOKUP(1,(MONTH($A$4:$A$11)=MONTH(TODAY()))*(YEAR($A$4:$A$11)=YEAR(TODAY())),$F$4:$F$11)

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

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