@NBVC:

this formula would not prevent same A's or B's etc. from appearing along the same row. how to achieve that?

thanks and regards.