Sounds like a job for an Array Formula (sorry a CSE formula). Have a look at this example, it sounds exactly liek what you're looking for.
http://www.mrexcel.com/tip011.shtml
Also, look up SUMIF function on Excel help.
Steven --
Either use:
(a) PivotTables (as you suggest yourself) where you can have Name as Page Field, Code as Row Field, and Spend as Data Field.
(b) a SUMIF formula that totals spendings per Code:
Assuming that A1:C5 houses your sample data:
activate A2,
activate Data|Filter|Advanced Filter,
Enter as Input range A1:A5,
Check Copy to another location,
Enter as value for Copy To F2,
check unique records only,
and click OK.
You'll get in F2:F5
{"Code";
111;
222;
333}
In G3 enter: =SUMIF($A$2:$A$5,F3,$C$2:$C$5)
Copy this as far as needed.
Aladin
==========