Trying to compare two dates and print the most recent plus seven years

Phily50

New Member
Joined
Jul 8, 2013
Messages
28
Office Version
  1. 365
Platform
  1. Windows
I'm getting myself in all sorts of a muddle with this formula.

I have two dates - one in cell D8 and one in cell E8. I want to find the most recent date and then add seven years to it which will then put that new date into cell J8. The reason I have used the isblank and iserror is because there is blanks (obvs!) and also some cells contain n/k for not known.

I have adapted this formula from one that was working before that only looked at one date - it was working - but now I have added E8 it has to compare the two rather than just look at one.

I dont really want it to show 01/01/1900 if one of the cells is blank or says n/k


VBA Code:
=IF(ISBLANK(DATE(YEAR(MAX(E8,D8))+ 7)), MONTH(MAX(E8,D8), DAY(MAX(E8,D8))),"",IFERROR(DATE(YEAR(MAX(E8,D8D8)))) + 7, MONTH(MAX(E8,D8(D8), DAY(MAX(E8,D8(D8)),""))))

Grateful of any help from you guys as always.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
NOt sure what you mean about blanks, do you mean blanks in E8 or D8?
Book4
DEF
7Date1Date2Max + 7
85/13/20228/15/20228/15/2029
9
Sheet1
Cell Formulas
RangeFormula
F8F8=EDATE(MAX(D8:E8),7*12)
 
Upvote 0
NOt sure what you mean about blanks, do you mean blanks in E8 or D8?
Book4
DEF
7Date1Date2Max + 7
85/13/20228/15/20228/15/2029
9
Sheet1
Cell Formulas
RangeFormula
F8F8=EDATE(MAX(D8:E8),7*12)

That formula works, however by blanks I mean just as you say - Blanks or n/k in E8 or D8. If theres only a n/k in one of the cells its fine, but if its in both (which some of the cells further down the sheet do have, it returns "31/12/1906". I'd rather it be blank or at the very least, 'N/K'
 
Upvote 0
try.
=IF(and(e8=0,d8=0),"",EDATE(MAX(D8:E8),7*12),""))
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Thanks for the tip!

My version is Microsoft® Excel® for Microsoft 365 MSO (Version 2202 Build 16.0.14931.20648) 32-bit

I have updated my profile to reflect this.
 
Upvote 0
Try checking to see if they are numbers:
=IF(AND(ISNUMBER(E8)=FALSE,ISNUMBER(E8)=FALSE),"",
EDATE(MAX(D8:E8),7*12),""))
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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