If I understand correctly you want to count the number of unique codes in column B that are associated with each location in column A. For that part of the solution I used two helper columns (which could be hidden for aesthetic purposes) and the formula:
Formula:
=COUNTIFS(A$2:A$10,A2,G$2:G$10,1)
I came up with a different value for location AA04 as there are two unique codes associated.
For column E try:
Formula:
=SUMIFS(D$2:D$10,A$2:A$10,A2)
This does give some different values from those listed in post #3, however the values yielded by the formula seem to be correct, again assuming that my understanding of the OP is correct.
Let me know if you have any questions.
Bookmarks