IF(C45<>"",C45,
IF(D45="","--",
IF(MONTH($T45)<>MONTH(N1),"D",
IF(SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="D")),"D",
IF(SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="A")),"P",
IF(SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="B")),"P",
IF(SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="C")),"P",
IF(SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="ZZZ")),"ZZZ",
"D"))))))))

Can anyone help me with this formula? It worked fine until I added the 3rd line, IF(MONTH($T45)<>MONTH(N1),"D",
When I copy and paste the formula I am not given any error message, instead the formula just becomes entered as text (I can see the formula in the cell rather than a result).

Thanks.

Dan