As for the second part of your question. You could accomplish it by using an IF formula to check what's in the 'Code' column then putting the value under the appropriate heading.
Look at the attached mock up of your file where I've put the below formula in E2 then copied it right and down as required.
Formula:
=IF($D2=E$1,$C2,"")
BSB
Bookmarks