Hi. Welcome to the forum.
I copied sheet B into a new tab in Sheet A and renamed it DocumentB, just to make it easier.
Then I use this formula in cell D2 and drag it across and down:
Formula:
=IFERROR(INDEX(DocumentB!$F$1:$F$1000,AGGREGATE(15,6,ROW($A$1:$A$1000)/(DocumentB!$C$1:$C$1000=$C2),COLUMNS($A$1:A$1))),"")
You can use the formula changing the references to a different workbook, but probably both workbooks must be open so the formula works.
Please check wb attached and let us know how it goes.
Good luck!
Bookmarks