I have the following formula in cell A2:51 (cell numbers are changed in each cell accordingly) =IF(AND(F2<1,UAL028!P$17>$P$1-8),"D, ","")& IF(OR(E2=U$20,E2=U$26,E2=U$32,E2=U$38),"T, ","") & IF(OR(E2=U$22,E2=U$28,E2=U$34,E2=U$40),"L, ","") & IF(OR(E2=U$21,E2=U$27,E2=U$33,E2=U$39),"N, ","") & IF(OR(E2=U$23,E2=U$29,E2=U$35,E2=U$41),"R, ","") & IF(F2=0,"F, ","") & IF( AND(F2 =0, OR( E2 = U$24, E2= U$30, E2 =U$36, E2 = U$42) ), "X", "" )

In cell O2 I have =COUNTIF(A2:A51, "=D") but it doesn't return any results. There are times when the cell value contains multiple letters (as you can see in the formula) and times when the cell is blank.

What is wrong with either formula?