Try array entering this formula in H2. Then fill down and across column I.
If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
Formula:
=IF($G2="","",INDEX(C$2:C$31,SMALL(IF($G2=$E$2:$E$31,ROW($E$2:$E$31)-MIN(ROW($E$2:$E$31))+1),COUNTIF($G$2:$G2,$G2))))
Then array enter this formula in J2 and fill down.
Formula:
=IF($G2="","",INDEX(F$2:F$31,SMALL(IF($G2=$E$2:$E$31,ROW($E$2:$E$31)-MIN(ROW($E$2:$E$31))+1),COUNTIF($G$2:$G2,$G2))))
Bookmarks