简体   繁体   English

如果日期在日期范围内,则更新单元格

[英]Update cell if today's date within date range

I'm trying to create a formula that will update a cell with a value only if today's date falls into the month and year specified. 我正在尝试创建一个公式,仅当今天的日期落入指定的月份和年份时,才会使用值更新单元格。

I have a value that constantly updates based off a table. 我有一个不断根据表更新的值。 I'd like the cells to the right of the dates (May-17, Jun-17, etc.) to update with the "Current" number of rows if today's date is within the date to the left. 如果今天的日期在左边的日期之内,我希望日期(5月17日,6月17日等)右边的单元格更新为“当前”行数。

For example, on May 31, 2017, the value in the cell to the right of "May-17" should be equal to the "Total Number of Rows" and starting on June 1, 2017, the May value will no longer update but the Jun-17 value will so as new projects are added, the May-17 value remains at 12 and the Jun-17 value increases. 例如,在2017年5月31日,“ 5月17日”右侧单元格中的值应等于“总行数”,并且从2017年6月1日开始,5月值将不再更新,但因此,随着新项目的添加,Jun-17值将保持不变,5月17日的值仍保持在12,Jun-17的值将增加。

在此处输入图片说明

The formula options I've played around with are: 我玩过的公式选项是:

=IF(MONTH(TODAY()) & YEAR(TODAY()) = MONTH(E7) & YEAR(E7),Total_Rows,"")

  • This one deletes the entry if we are not in that date range, which I do not want 如果我们不在该日期范围内,则此条目将删除该条目,我不希望
  • Is there a way to have the value of the cell be the value if the IF statement is false? 如果IF语句为false,是否有一种方法可以使单元格的值成为值?

= SUMIF(E7,TEXT(E7,"mmm-yy") = TEXT(TODAY(),"mmm-yy"),Total_Rows)

  • This returns a value of 0 返回值0

You can do it with your formula and enabling iterative calculations. 您可以使用公式来启用迭代计算。

First, change the "" to refer to itself: 首先,将""更改为引用自身:

=IF(MONTH(TODAY()) & YEAR(TODAY()) = MONTH(E7) & YEAR(E7),Total_Rows,F6)

Next, go to File-->Options-->Formulas. 接下来,转到“文件”->“选项”->“公式”。 check Enable Iterative calculation and put the Maximum Iterations to 1 . 选中“ Enable Iterative calculation然后将“ Maximum Iterations1

在此处输入图片说明

Now when it is not the month it will refer to itself in a circular formula that you are currently allowing and it will remain itself. 现在,当不是月份时,它将以您当前允许的循环公式引用自己,并且它将保持不变。

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

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