Hi everyone,

I got a formula to calculate the sum of largest 10 cells in a specified range:

=IFERROR(SUMPRODUCT(A1:A100,--(A1:A100>=LARGE(A1:A100,10))),"-")
The problem with this formula is that if there are duplicates in the range, then the number is unexpected. For example, if the largest 20 cells all have a value of 5, then the formula will sum up all these 20 cells. But actually I just want to sum up the only 10 cells, even if there are duplicates.

Can you give me a UDF which returns the sum of the top N cells, if I supply the range and N value? For example, SumTopN(Rng1,N). This UDF will always return the exactly largest N cells even if there are duplicates.

It might be interesting too if a simple Excel formula will do the job.