sorry I misread your question. Try the following
- add a helper column with the following formula in C1
=IF(COUNTIF($A$1:$A1,A1)=1,"Use","")
copy this down for all rows
Now use the following formula
=SUMIF($C$1:$C$5000,"Use",$B$1:$B$5000)
...
This is a speed-storage trade-off. First, if you're going to use a 'helper
column', make it something efficient, e.g., just
C1:
=COUNTIF($A$1:$A1,A1)
then simplify the SUMIF formula as
=SUMIF($C$1:$C$5000,1,$B$1:$B$5000)
Numeric comparisons are MUCH FASTER than string comparisons.
The formulas above require 5000 additional cell formulas. That's going to eat at
least 40KB of storage (using an extremely optimistic estimate of 8 bytes for
each formula). These formula save time by only looking backward through col A.
The smaller storage but slower recalc alternative involves avoiding 'helper
columns' in the first place. One work-alike for the formula above would be
=SUMPRODUCT((MATCH($A$1:$A$5000,$A$1:$A$5000,0)=ROW($A$1:$A$5000)
-CELL("Row",$A$1:$A$5000)+1)*$B$1:$B$5000)
An alternative based on a different interpretation of the OP's specs, i.e.,
exclude all entries for which the col A entry appears more than once in col A,
even the *FIRST* such entry, would be
=SUMPRODUCT((COUNTIF($A$1:$A$5000,$A$1:$A$5000)=1)*$B$1:$B$5000)