Hi,
Your range (without trim) and criteria (with trim) are Not Equal.
COUNTIF(s) will not allow range to be wrapped with Trim, but Sumproduct seems to be working here:
=IF(A6<>"",IF(SUMPRODUCT((TRIM(A$6:A$24)=TRIM(A6))+0)>1,"Duplicate",""),"--")
Regards,