So Ted.

In I6 of my example, put this ARRAY formula...

=INDEX($C$2:$C$14,MATCH(IF(SUMPRODUCT(($A$2:$A$14=$G6)*($B$2:$B$14=$F$1)),"",MAX(IF($A$2:$A$14=$G6,IF($B$2:$B$14=$G$1;$D$2:$D$14)))),$D$2:$D$14,0))
This will gives you "a0006" as result.