+ Reply to Thread
Results 1 to 5 of 5

sum a range until the cell to the left is zero

  1. #1
    Registered User
    Join Date
    09-16-2013
    Location
    Crossville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    sum a range until the cell to the left is zero

    I want to get the years old column/cells
    that would look to the left and calculate
    the numbers of years an account is…

    For example above, row 2 - should return
    a 3, as the account is 3 years old

    Row 3 needs to be a 1….
    meaning stop counting going to the left
    once a cell that is "0" is reached.
    See attached file
    Attached Files Attached Files

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

    Re: sum a range until the cell to the left is zero

    you could try this
    =IFERROR(SUM(INDEX(A2:F2,LOOKUP(2,1/(A2:F2=0),COLUMN(A2:F2))+1):INDEX(F2,0)),0)
    "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

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: sum a range until the cell to the left is zero

    Hi, and welcome to the forum.

    There's no doubt an array formula but perhaps a User Defined Function (UDF)

    Please Login or Register  to view this content.
    After putting the function above in the VBE at the Module level, in G2 enter
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    09-16-2013
    Location
    Crossville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    Smile Re: sum a range until the cell to the left is zero

    You Freaking Rock!!!!

    Thank you so much

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: sum a range until the cell to the left is zero

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. [SOLVED] Deselect all cells in range except top left cell
    By pkew22 in forum Excel General
    Replies: 2
    Last Post: 07-23-2013, 03:44 PM
  2. Mix of non-empty cell range search & left vlookup
    By wouZa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-22-2013, 02:47 PM
  3. [SOLVED] Unselect Range to top left cell
    By pkew22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2013, 01:49 PM
  4. Content of cell in upper left corner in a range
    By mkvassh in forum Excel General
    Replies: 4
    Last Post: 10-07-2011, 03:15 AM
  5. Replies: 2
    Last Post: 06-29-2006, 02:00 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