Compare dates of two cells in excel

久未见 提交于 2019-12-25 05:12:13

问题


I have dates in E2 and F2 cells of an excel.The dates are in MM/DD/YYYY fromat.I want to apply validation in such a manner that date in F2 must be greater then dates in E2 . In case of failure we should display an error. I am using Microsoft Office 2007.

Help would be appreciated.


回答1:


You could use conditional formatting? In your case the background of one of the dates could turn red if the date is too low compared to another.

Quick google: http://www.homeandlearn.co.uk/excel2007/excel2007s6p2.html




回答2:


Should be quite easy doing =IF(F2>E2;"SUCCESS";"ERROR")

You can omit the "SUCCESS" and you only display the error should it fail. This will work as long as the fields are actually formatted as a proper date.

Updated code:

=IF(AND(NUMBERBLANK(E2:F2)=0;F2<E2);"ERROR";"")

What this does is: Check if both cells are filled, if they are chech if E is smaller than F, and write ERROR if that is the case.

To do this for the entire column you need to replicate the formula. For existing dates, just double click the lower right knob in the cell the formula is, and it SHOULD replicate down till the end of the row (if the row is next to the date). Other than that, just pull the knob down as far as you need it.



来源:https://stackoverflow.com/questions/10583970/compare-dates-of-two-cells-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!