Here is a simple formula that may help.
Given the data here:
a b c
12345 1 1
6789 2 2
12345 1 1
6789 2 2
12345 1 1
6789 2 2
Item Result
12345 6
6789 12
To get the results. 12345:
=SUM(SUMIF(A1:A6,"12345",B1:B6)+SUMIF(A1:A6,"12345 ",C1:C6))
and
6789:
=SUM(SUMIF(A1:A6,"6789",B1:B6)+SUMIF(A1:A6,"6789", C1:C6))
HTH, Tony