0

I'm subtracting 2 dates. If the dates are <=5 then the answer is Y, if not then the answer is N. How do I ignore blank cells so I don't automatically get a Y? This is the formula I'm using.

=IF(G2-C2<=5,"Y","N")

  • Add a second IF for your "N" case. – StainlessSteelRat Aug 17 '21 at 15:10
  • Does this answer your question? [Display Blank when Referencing Blank Cell in Excel 2010](https://superuser.com/questions/515932/display-blank-when-referencing-blank-cell-in-excel-2010) – Toto Aug 17 '21 at 16:14
  • It doesn't ignore the blanks, but you might be able to use an absolute value. ABS(G2-C2)<=5. If either cell is blank, you'll get a value much greater than 5. Also, with an absolute value, the order of the dates won't matter which can be appropriate for some uses. – will Aug 17 '21 at 18:40

1 Answers1

1

One way among many others is to use ISBLANK, OR, and nested IFs:

=IF(OR(ISBLANK(C2),ISBLANK(G2)),"",IF(G2-C2<=5,"Y","N"))
mpez0
  • 2,792
  • 1
  • 16
  • 20
Rubén
  • 693
  • 6
  • 18
  • @Julie Wood, when the only cell in column C is blank, it will automatically get "N", but when the only cell in column G is blank, it will automatically get "Y". You could also choose to use the ISBLANK function for column G only. Also note that when G2-C2 is negative, "Y" will also be returned. – Viki Ji Aug 18 '21 at 06:54