Or try this in cell E2 ...

=IF(D2="","",IF(N(D2)>C2,D2,EDATE(C2,IF(COUNTIF(D2,"*Months*"),--SUBSTITUTE(D2," Months",""),12*SUBSTITUTE(D2," Years","")))))

Copy down.