leopardhawk

Well-known Member
Joined
May 31, 2007
Messages
611
Office Version
  1. 2016
Platform
  1. Windows
Regarding this formula:

If there are dates in E8 (September 23, 1953) and H8 (April 1, 2017) the formula is returning "Started pension at 63 years and 6 months of age.". This is good.

If both cells are blank, the formula is returning "Started pension at 0 years and 0 months of age." which is also good.

However, for practical purposes, there will be situations where H8 will be blank and if it is, then I am receiving a #NUM ! error.

What I am trying to accomplish is that the formula should also return "Started pension at 0 years and 0 months of age." if H8 is blank. Is this possible?

Code:
="Started pension at "&DATEDIF('personal information'!E8,'personal information'!H8,"y")& " years " &DATEDIF('personal information'!E8,'personal information'!H8,"ym")&" months of age."
Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You'll need to nest an IF/IFERROR statement, DATEDIF can't compare a legit date to a blank cell (when entering legit date as parameter 1), as the compared date (cell H8) must be equal or greater than the initial date (cell E8).

So you could say if E8 is greater than H8 then return "Started pension at 0 years 0 months of age." Otherwise have it run the formula you posted.

Like so:

Code:
IF('personal information'!E8>'personal information'!H8,"Started pension at 0 years 0 months of age.","Started pension at "&DATEDIF('personal information'!E8,'personal information'!H8,"y")& " years " &DATEDIF('personal information'!E8,'personal information'!H8,"ym")&" months of age.")
 
Last edited:
Upvote 0
Thank you so much Tyija, that works perfectly. Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top