You could do this with a long an complicated formula, or you could use a helper column (Red text in the attached) and a simple INDEX/MATCH.
The results are the same as in your example workbook, but in a slightly different order.
Was there a reason they were ordered as such in yours?
BSB
Bookmarks