if AF, AG and AH are empty or blank cells in that row.

=IF(AG859=AH859,IF(AF859<>AG859,"A","A"),"A")

=IF(AND(AG859=AH859,AG859=AF859),"A",IF(AND(AF859<>AH859,AG859<>AF859,AG859<>AH859),"B",IF(AND(AF859=AG859,AH859<>AF859,AH859<>AG859),"A",IF(AND(AG859=AH859,AF859<>AG859,AF859<>AH859),"B",IF(AND(AF859=AH859,AG859<>AF859,AG859<>AH859),"B","A")))))

=IF(AND(AH859=AF859,AH859=AG859),"A",

IF(AND(AF859<>AG859,AH859<>AF859,AH859<>AG859),"C",

IF(AND(AF859=AG859,AH859<>AF859,AH859<>AG859),"B",

IF(AND(AF859=AH859,AG859<>AF859,AG859<>AH859),"A",

IF(AND(AG859=AH859,AF859<>AG859,AF859<>AH859),"B","A")))))

Thanks