简体   繁体   English

Excel公式在某些单元格上返回false

[英]Excel formula returning false on certain cells

I have a nested IF statement in excel in several columns that is returning FALSE on certain cells. 我在Excel中的几列中都有一个嵌套的IF语句,该语句在某些单元格上返回FALSE。

=IF(DATEDIF(B2,C2,"y")<5,3.077,IF(AND(DATEDIF(B2,C2,"y")>5,DATEDIF(B2,C2,"y")<10),3.5385,IF(AND(DATEDIF(B2,C2,"y")>10,DATEDIF(B2,C2,"y")<15),3.846,IF(AND(DATEDIF(B2,C2,"y")>15,DATEDIF(B2,C2,"y")<20),4.308,IF(AND(DATEDIF(B2,C2,"y")>20),4.615)))))

These work: 这些工作:

B2 - 2/3/95, C2 - =Today() B2-2/3/95,C2-= Today()

B2 - 2/21/08, C2 - =Today() B2-2/21/08,C2-= Today()

B2 - 9/1/99, C2 - =Today() B2-9/1/99,C2-= Today()

These don't: 这些不:

B2 - 2/6/12, C2 - Today() B2-2/6/12,C2-今天()

B2 - 3/1/07, C2 - Today() B2-2007年3月1日,C2-今天()

B2 - 12/8/11, C2 - Today() B2-12/8/11,C2-今天()

B2 - 3/31/97, C2 - Today() B2-3/31/97,C2-今天()

Any help would be greatly appreciated. 任何帮助将不胜感激。

Your problem is that you have created a 'pocket' where the difference in years in neither less than 5 or greater than 5; 您的问题是您创建了一个“口袋”,其中年差不小于5或不大于5; in other words, 5. You could fix this by adding an equal sign to one of them; 换句话说,5.您可以通过向其中一个添加等号来解决此问题; eg <= 5 or >=5. 例如<= 5或> = 5。

However, you might also wish to use the logic of an IF statement and reduce your formula substantially. 但是,您可能还希望使用IF语句的逻辑并大幅减少公式。 Once you test for less than 5 you know that anything that continues in the FALSE processing portion of that IF is going to be 5 or greater. 一旦测试少于5个,您就会知道在IF的FALSE处理部分中继续进行的所有操作将等于或大于5。 You do not have to test for that. 您不必为此进行测试。

=IF(DATEDIF(B2,C2,"y")<5, 3.077,
 IF(DATEDIF(B2,C2,"y")<10, 3.5385,
 IF(DATEDIF(B2,C2,"y")<15, 3.846,
 IF(DATEDIF(B2,C2,"y")<20, 4.308,
  4.615))))

This can also be written as a LOOKUP function. 这也可以写为LOOKUP函数。

=LOOKUP(DATEDIF(B2,C2,"y"), {0,5,10,15,20}, {3.077,3.5385,3.846,4.308,4.615})

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

相关问题 excel中的嵌套IF公式返回“False” - Nested IF formula in excel returning "False" Excel 中的 IF 公式在 26.00% &gt;= 10.01% 时返回 FALSE - IF Formula in Excel returning FALSE on 26.00% >= 10.01% Excel 搜索带空格的特定单元格后返回真假的公式 - Excel Formula to return true false after searching for specific cells with blanks Excel公式搜索范围内的所有单元格是否都显示为“True”,如果不是,则显示“False” - Excel formula to search if all cells in a range read “True”, if not, then show “False” Excel公式:列中唯一单元格的数量,IF对应的行是一定值 - Excel formula: count of unique cells in column, IF corresponding row is certain value EXCEL公式-CountIf-如何排除满足特定条件的单元格 - EXCEL formula - CountIf - how to exclude cells that meet a certain criteria 如果在另一个单元格中输入了某个值,是否有一个Excel公式填充多个单元格? - Is there an Excel formula that populates a number of cells, if a certain value is entered in another cell? Excel-JSON数据-将某些元素返回到相邻的单元格公式/宏 - Excel - json data - return certain elements to adjacent cells formula/macro Excel 某些单元格组合将返回值的公式 - Excel formula where certain combinations of cells would return a value Excel公式根据特定条件对所选单元格进行平均 - Excel formula to average selected cells based on certain criteria
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM