Search code examples
exceldatecellformula

Excel Formula for Dates, But Excluding Empty Cells


I didn't find anything that quite fits my task. I'd like to identify cells in an Excel spreadsheet that contain dates before a specified date, but exclude the cells with spaces. Here's my current formula:

=IF(A2<=DATE(2019,2,8),"YES","")

Which produces:

Screenshot of Spreadsheet

However, I also want to exclude the cells with spaces. I tried:

=IF(and((isnumber(a2)),(A2<=DATE(2019,2,8))),”YES","")

But that didn't work. I'm close, but missing a piece of the puzzle.


Solution

  • in your formula

    =IF(and((isnumber(a2)),(A2<=DATE(2019,2,8))),”YES","")
    

    you are closing the AND() brackets too early. (you also have fancy quotes in front of the Yes). Don't go overboard with brackets. It makes it harder to keep track of what's what. This one should work:

    =IF(and(isnumber(a2),A2<=DATE(2019,2,8)),"YES","")
    

    enter image description here