why not just, assuming headers are in row 1, data starts in row 2...

=SUM(C1,IF(A2=B2,C2,0))