In Excel 2003 and earlier you cannot nest more than 7 IF() functions. Split the logic into different cells.
Or try
=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(OR(
SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="A")),
SUMPRODUCT(--(P45:P50=D45),--(Q45:Q50=E45),--(R45:R50=G45),--(S45:S50="B")),
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"))))))
cheers,
Bookmarks