#### Evagrius Ponticus

##### Well-known Member

- Joined
- May 24, 2007

- Messages
- 1,467

Below is my primitive formula. It works, but it's tough to work with when making changes. I have absolutely no more room in the formula bar All the cells referenced contain dates excpet column P. Can anyone see a way to compact the formula without altering the reuslt?

Code:

`=IF($E$7="","",IF(AND($P16="y",$Q16<=X$14,$R16>X$14,$R16-X$14>=365),"12m",IF(AND($P16="y",$Q16<X$14,$R16>X$14,$R16-X$14<365),DATEDIF(X$14,$R16,"m")&"m. "&DATEDIF(X$14,$R16,"md")&"d",""))&IF(AND($R16<=X$14,$S16-X$14>=365),"X",IF(AND($R16<X$14,$S16>X$14,$S16-X$14>0,$S16-X$14<365),DATEDIF($S16,Y$14,"m")&"m. "&DATEDIF($S16,Y$14,"md")&"d",""))&IF(AND($S16<=X$14,$T16-X$14>=365),"12m","")&IF(AND($S16<X$14,$T16-X$14<365,$T16-X$14>0),DATEDIF(X$14,$T16,"m")&"m. "&DATEDIF(X$14,$T16,"md")&"d","")&IF(AND($P16="y",$Q16>X$14,Y$14-$Q16<365,Y$14-$Q16>0),DATEDIF($Q16,Y$14,"m")&"m. "&DATEDIF($Q16+1,Y$14,"md")&"d",IF(AND($Q16>=X$14,OR(Y$14-$Q16<=0,Y$14-$Q16>365)),"X",""))&IF(AND($T16<=X$14,$U16-X$14>=365),"X","")&IF(AND($U16<=X$14,$V16-X$14>=365),"12m",IF(AND($U16<=X$14,$V16-X$14<365,$V16-X$14>0),DATEDIF(X$14,$V16,"m")&"m. "& DATEDIF(X$14,$V16,"md")&"d",""))&IF(AND($P16="n",$Q16<X$14,$R16-X$14>=0),"X","")&IF(AND($U16>X$14,$U16-X$14<365),DATEDIF($U16,Y$14,"m")&"m. " &DATEDIF($U16,Y$14,"md")& "d","")&IF(AND(X$14>$V16),"-",""))`