Have you tried doing this with VLOOKUP of INDEX/MATCH?

PS Using code of course.