I imagine that this can be improved on.
1) On sheet2 FL1:FN1 are populated using: =INDIRECT("Sheet1!S"&COLUMN(C:C))
2) FL2:FN10 are populated using: =IFERROR(INDEX($A2:$FJ2,MATCH(FL$1,$A2:$FJ2,0)+1),"")
3) FL11:FN11 are populated using: =SUMPRODUCT((FL2:FL10<>"")*(ROW(2:10)-1))
Note that you could cut and paste cells FL11:FN11 to a row further down (i.e. anywhere below the last possible row of data) of sheet2.
4) On sheet1 the formula that populates U3:U4 is:
Formula:
=INDEX(Sheet2!FL$2:FN$3,INDEX(Sheet2!FL$11:FN$11,MATCH(S3,Sheet2!FL$1:FN$1,0)),MATCH(S3,Sheet2!FL$1:FN$1,0))
Let us know if you have any questions.
Bookmarks