I recently needed to make sure that I had three codes in a row of data with no duplicates, so I used the following formula (a1, a2, and a3 being the codes):
=IF(SUM(COUNTIF(C2:H2,"a1")=1, COUNTIF(C2:H2,"a2")=1, COUNTIF(C2:H2,"a3")=1 SUM(COUNTIF(C2:H2,"a1"), COUNTIF(C2:H2,"a2"), COUNTIF(C2:H2,"a3")), "err", SUM(COUNTIF(C2:H2,"a1"), COUNTIF(C2:H2,"a2"), COUNTIF(C2:H2,"a3")))
This gives me a count (up to 3) of unique codes and an "err" if a duplicate code is found.
It might not be very pretty or elegant, but it works.

































