+ Reply to Thread
Results 1 to 6 of 6

Return with sum of top 10 cells in a range which has duplicates

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Return with sum of top 10 cells in a range which has duplicates

    Hi everyone,

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

    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2504
    Posts
    19,371

    Re: Return with sum of top 10 cells in a range which has duplicates

    Try this instead:
    Please Login or Register  to view this content.
    Let me know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Return with sum of top 10 cells in a range which has duplicates

    Try these two formulas to sum top 10 of unique values

    enter as a regular formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    or an array formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ***Array formula must be entered by using key combination of CTRL+SHIFT+ENTER and not just ENTER

    for helper column use this formula in B2 and copy down

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    D
    1
    Values Helper Result
    2
    25
    1
    288
    3
    25
    2
    4
    32
    1
    5
    48
    1
    6
    25
    3
    7
    37
    1
    8
    45
    1
    9
    32
    2
    10
    8
    1
    11
    12
    1
    12
    45
    2
    13
    32
    3
    14
    56
    1
    15
    45
    3
    16
    32
    4
    17
    19
    1
    18
    6
    1
    19
    8
    2
    20
    4
    1
    Sheet: Sheet1
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Re: Return with sum of top 10 cells in a range which has duplicates

    Many thanks, JeteMc and AlKey. Both of you give me very advanced Excel formulas. Thanks a lot.

    Just wondering if there is a handy UDF which can also make it work. I guess for a lot of VBA gurus, this is a simple question

  5. #5
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Re: Return with sum of top 10 cells in a range which has duplicates

    I just created a UDF:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2504
    Posts
    19,371

    Re: Return with sum of top 10 cells in a range which has duplicates

    RE: Post #5 Congratulations. RE: Post #4 You're welcome and thank you for the feedback. Please take a moment to mark the thread 'Solved' using the thread tools link above your first post. Hope that you have a good day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 07-30-2014, 02:37 PM
  2. [SOLVED] Lookup specific value in range of duplicates return if true
    By maddog9486 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-27-2013, 02:54 PM
  3. Finding duplicates within a range of cells.
    By vitormoreira89 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-20-2012, 03:34 PM
  4. Replies: 2
    Last Post: 11-12-2012, 06:26 AM
  5. Replies: 24
    Last Post: 04-15-2009, 09:24 AM
  6. Want to return 'TRUE' if text duplicates in multiple cells
    By ddub25 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-11-2007, 08:22 AM
  7. AVOIDING DUPLICATES IN A RANGE OF CELLS
    By Glint in forum Excel General
    Replies: 12
    Last Post: 08-09-2006, 06:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1