+ Reply to Thread
Results 1 to 21 of 21

Sum and mark largest 5 numbers from selected range within column

  1. #1
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Sum and mark largest 5 numbers from selected range within column

    Hi,

    I'm trying to find a way to sum the 5 largest numbers in a column. I was using the LARGE function, however, it appears that the LARGE function only uses named ranges. Data will be coming into the worksheet daily and the ranges would change daily, so I need something to be more flexible with ranges.

    In the attached spreadsheet the columns highlighted in yellow I'm looking to find an answer to, given the above whereby I need the ranges to be changed within the formula somehow...unless there's another solution!

    Please help, I'm desperate!

    Thanks,
    SS.
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Sum and mark largest 5 numbers from selected range within column

    try this in K2:

    =SUMPRODUCT(LARGE(D$2:D$40, ROW($A$1:$A$5)))

    (and pull to L2)

  3. #3
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    I've used =SUM(LARGE('range here',{1,2,3,4,5})). That works if the range is known, however, the range will change daily. I used ="$A$"&MATCH(A10,A:A,0)&":$A$"&MATCH(A10,A:A,0)+COUNTIF(A:A,A10)-1 to give me the range that I require, but I don't know how to use that within the LARGE function.

  4. #4
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    Can anyone please advise if this is even possible?

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Sum and mark largest 5 numbers from selected range within column

    You could use Named Dynamic ranges

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Are you sure that gives the range you want? You are indexing column A and then matching to a row in column A... how is that defining the range?

    using your logic:

    =SUMPRODUCT(LARGE(INDEX(A:A,MATCH(A10,A:A,0)):INDEX(A:A,MATCH(A10,A:A,0)+COUNTIF(A:A,A10)-1),ROW($A$1:$A$5)))

    but maybe it would be better if you literally described how you want to define the dynamic range?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  7. #7
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    Sorry, you would have to replace A10 with A2 to get the correct range for the example spreadsheet, I copied it from another workbook. My apologies.

    The formula you've given above produces #NUM error.

    I need to name the ranges according to the PF column being the same, ie, all for GART1 and all for GART2. Each day, there will be varying amounts for GART1 and GART2. I've just had a read of your Dynamic Named ranges and it looks as though it may be what I'm looking for.

    Would you mind further explaining how that might work in my scenario?

    Thanks,
    SS.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    All you should need is a start and end cell. How do you determine what the start and end cells are... (i.e the start and end rows).

    Maybe a sample workbook might help.

  9. #9
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    It is determined by that which is in column A in the example workbook I previously attached. So each range will start where there is a new value in column A. In my example the ranges I'd be looking to produce would be GART1 RNG which should be $A$2:$A$26 and a GART2 RNG which should be $A$27:$A$40. Come the next day, if there were 20 more entries for GART1 (column A is sorted from the original output) I'd need the dynamic range for GART1 RNG to be $A$2:$A$46 and GART2 RNG would be $A$47:$A$60.

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Will this work?

    Please Login or Register  to view this content.
    confimed with CTRL+SHIFT+ENTER and copied down.

    If you want to show the value only at the first occurance of the PF (and also reduce the array formula calcs), then try:

    Please Login or Register  to view this content.
    confirmed with CTRL_+SHIFT+ENTER and copied down.

    and if you want to exclude 0's from the LARGE calculations....

    Please Login or Register  to view this content.
    confirmed with CTRL_+SHIFT+ENTER and copied down.


    These formulas can be copied to next column to get column E sums...

  11. #11
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    Brilliant! That's part one of the problem solved!

    Part 2 is the next 2 columns in the spreadsheet M & N where I need to somehow mark which of the GART1 and GART2 LMV's/SMV's are the top 5 per PF as I need to apply a separate calc specifically to those. A simple Yes or X or any sort of indication is fine.

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Which formula above did you use? I.e. are you including or excluding 0's?

  13. #13
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    I used the last one as it worked the best, however, if you require me to use any of the others I'm sure it's fine. Although, it seems that the last one was the only one that worked when used in column E.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Ok then try:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER copied to next column and down.

    You can replace "Mark" with whatever marker you want.. even $A2 so you can separate the PF's

  15. #15
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    NBVC, You're an absolute legend, mate!

    I've got one little problem though that I can't seem to sort out. On the test example when I copied down the top 5 sum formula (the last of your three examples) when it got to GART2 it was fine. On the spreadsheet I'm actually working on I got an error #NUM. I can't really see that there's any difference. The only thing that's bothering me is that when it changes PF there's no value in LMV. And the values for GART2 are exceptionally large (100,000,000,000.00). Could either of these cause this issue to occur?

    I know you most likely hear this a million times, but I have triple checked that I have changed the cells correctly and I have as the first calc works perfectly.

    Very odd. Any ideas? I'd love to post the actual spreadsheet on here for you but it has somewhat sensitive data, is there any way I can post it on here and then delete it after you've viewed it, or send it only to you???

    Thanks so much, you've helped me out no end and I was racking my brains trying to find this solution!

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    None of those 2 issues should cause the problem....

    The only thing I can think of immediately is that you might have a PF that has less than 5 qualifying (i.e. non-zero) values in LMV column, therefore it can't get a Large(range,5) value .... is that a possibility?

  17. #17
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    I've figured it out! On my actual workbook there's not 5 LMV's or SMV's so the end of the formula ...{1,2,3,4,5} needed to be changed to the exact amount of LMV's that there are.

    Can you think of any possible ways to get around this? I'm honestly happy for it to be like this but if you could find a solution to that, you'd be awesome!

    Cheers,
    Scott.

  18. #18
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    Looks like you beat me to that too!!

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Ok try these:

    For Sum of top 5 LMV by PF:

    Please Login or Register  to view this content.
    CSE key confirmed and copied down and to next column

    For Marker for top 5 LMV:

    Please Login or Register  to view this content.
    CSE key confirmed and copied down and to next column

    Also, note that if you have more than 1000 rows in the database, you will need to adjust ranges to suit in those formulas.
    Last edited by NBVC; 05-19-2011 at 12:15 PM.

  20. #20
    Registered User
    Join Date
    06-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Sum and mark largest 5 numbers from selected range within column

    Oddly enough, the first one you did for the marking was perfect and didn't need amending!

    This last formula is magnificent - I have absolutely no idea how it works, but it's works perfectly. Doesn't get rid of the zero values, but I have no care with those anyway.

    Thanks ever so much. I've hit the scales as many times as this will let me.

  21. #21
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sum and mark largest 5 numbers from selected range within column

    Actually the first formula in my last post didn't include the initial check so that it only posts the result once per grouping. It should be:

    Please Login or Register  to view this content.
    Also, not sure what you mean by: Doesn't get rid of the zero values... the formulas should ignore zero values in the D and E columns...
    Last edited by NBVC; 05-19-2011 at 12:35 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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