View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Need IF/THEN formula for date present

Or, for something more robust:
=IF(COUNT(A2),IF(ISNUMBER(B2),B2,TODAY())-A2,"")


Same result, a few keystrokes shorter:

=IF(COUNT(A2),IF(COUNT(B2),B2,TODAY())-A2,"")


If we make the assumption that if a date exists in B2, that it will always
be an earlier date than today, then we can save a few more keystrokes...

=IF(COUNT(A2),MIN(B2,TODAY())-A2,"")

or, if not always earlier, then if we assume it is always after today,
then...

=IF(COUNT(A2),MAX(B2,TODAY())-A2,"")

Rick