=IF(ISNUMBER(FIND("AA",A1)),"AA",IF(ISNUMBER(FIND("BB",A1)),"BB",IF(ISNUMBER(FIND("CC",A1)),"CC",0)))