+ Reply to Thread
Results 1 to 15 of 15

Sum

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    Sum

    Hi hope someone can help

    I have two columns and the data is sorted in ascending order using column A. What I would like to do is find the largest sum of consecutive numbers in column B (whether that is a single cell, or all the cells). Looking at the data below I have manually highlighted the highest sum of consecutive cells. Is there anything I can use that would do this automatically?

    See attachment.

    I am sure it is dead easy I can't do it
    cheers!
    Attached Images Attached Images
    Last edited by bradbua; 11-19-2009 at 07:59 PM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    re: Sum

    Hi,

    I don't understand something, so perhaps you can clarify.

    As far as I can see, the highest consecutive sum is B9:B23, which is a sum of 15.15.

    But you have highlighted B9:B15, which is a sum of 12.15.

    Is that a mistake or have I misunderstood the question?
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    re: Sum

    Hi Colin

    Thanks for pointing that out - I made a mistake and that is exactly why I want Excel to do it automatically!

    Can you help?
    cheers

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    re: Sum

    Hi,

    In the scenario that multiple sequences all give the highest cumalitive sum, which cells should be highlighted?

    eg. If you had 1,-1,1
    The highest cumulative sum is 1. That could be the first 1 or the last 1 considered individually, or it could be all three considered togther.

    or, if you had
    1,2,-1,1,-10,1,1,1
    The highest cumulative sum is 3. This could be either the first two numbers, or the first four numbers, or the last three numbers.
    Last edited by Colin Legg; 11-13-2009 at 10:40 AM.

  5. #5
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    re: Sum

    Ah very good point. It should highlight the most cells. So in your first example it should highlight all 3 cells and in your second example it should highlight the first 4 numbers.
    Thanks.

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    re: Sum

    Okay, last question then. What if two separate sequences have the same length?

    eg. 1,1,1,-10,1,1,1

    Which should be highlighted?

  7. #7
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    re: Sum

    Well I'm hoping that won't happen too often but I think the best option would be to highlight all sequences that are the same length.

    thanks again

  8. #8
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    re: Sum

    To account for all these features I think we're looking at a VBA solution. If that's acceptable for you then I'll try to put something together for you this weekend. Approximately how many items do you expect there to be in the column?

  9. #9
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    re: Sum

    I'm expecting the column data to be about twice as long (or maybe a bit more) as the example I attached originally.
    Thank you so much for looking at this. If you come up with something that would be amazing.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum

    Try the attached.
    Attached Images Attached Images
    Entia non sunt multiplicanda sine necessitate

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sum

    an image SHG?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum

    Image in, image out ...

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sum

    i thought as much lol

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sum

    Forgot about this ...
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-13-2009
    Location
    manchester, england
    MS-Off Ver
    Microsoft 365
    Posts
    10

    Re: Sum

    That was spot shg. Cheers for that!

+ 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