Hello,

create a pivot table with the codes in the row labels, the value of column B in the Value pane, set "max" as the value field settings and filter the data by the desired value in column D.