Excel 2007
Formula in S3:
=SUMPRODUCT(--
(D3:D20,D23:D47,D51:D67,D70:D74,D77:D124,D129:D140,D143:
D153,D156:D157=R3),P3:P20,P23:P47,P51:P67,P70:P74,P77:P12
4,P129:P140,P143:P153,P156:P157)
Column D contains Amount in numericals.
Column R3 is a Helper Cell containing name like KM in general...