+ Reply to Thread
Results 1 to 7 of 7

SUM below - until the next non-blank cell

  1. #1
    Registered User
    Join Date
    02-10-2011
    Location
    Canada
    MS-Off Ver
    Excel 2019 / MS365
    Posts
    55

    SUM below - until the next non-blank cell

    I'm having difficulty in writing a formula that will conditionally total values until the next non-blank cell in an adjacent column. Column 'A' contains the category labels (the individual titles do not repeat are not repeated - subsequent rows that are contained in the same category are represented as blank). Column 'B' contains the values for each line item. Column 'C' is where I want to include a formula that provides the category totals. the category totals must be at the TOP of the category, in the same row as the category labels. It is possible that Column 'B' may have blank cells, so that column cannot be used for any COUNT functions. Column 'A' seems to be the one with a consistent pattern - it either contains a label or is blank.
    The user will be inserting and/or deleting rows to accommodate additional line items, and cannot be relied upon to modify a typical SUM function range. The desired function must by dynamic, as far as the number of rows to include in the sum. The screenshot and attached worksheet represent only a small portion of the actual. There are numerous spreadsheets, and numerous category labels on each. I am familiar with dynamic ranges, but cannot see that working very well in this application.
    Thanks in advance for any help that you may provide,

    SUM screenshot.jpg
    Attached Files Attached Files
    Last edited by pinebush; 03-14-2014 at 06:28 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: SUM below - until the next non-blank cell

    This array formula in C2 dragged down will work (Array formulas are entered with CONTRL SHFT ENTER instead of ENTER. You'll see {} around formula if done properly)

    =IFERROR(IF(ISTEXT(A2),SUM(B2:INDEX(B2:B100, MATCH(1, 1/ISTEXT(A3:A101),0))),""),SUM(B2:B100))
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: SUM below - until the next non-blank cell

    Try array formula in C2:

    =IF(A2="","",SUM(B3:INDEX(B3:$B$17,MATCH(TRUE,A3:$A$17<>"",0),)))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    You could find error in last row, it can be solved, but it is not a big problem, right?
    Quang PT

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: SUM below - until the next non-blank cell

    In this scenario a vba code will be perfect rather than a formula. Try this code to get the desired result........
    Please Login or Register  to view this content.
    For detail please see the attached sheet.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    02-10-2011
    Location
    Canada
    MS-Off Ver
    Excel 2019 / MS365
    Posts
    55

    Re: SUM below - until the next non-blank cell

    Thank you. That seems to work. I suspect that I can/should use absolute references when referring to the bottom of the range (e.g. SUM(B2:$B$100). I am fascinated by your formula, and am curious as to what part the IFERROR function plays.
    Thanks for your prompt response.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: SUM below - until the next non-blank cell

    I put in the IFERROR because, as Bebo stated, the last entry will result in an error. When this happens, the IFERROR directs it to SUM(B2:B100) which would just sum the remaining cells in B.

  7. #7
    Registered User
    Join Date
    03-27-2017
    Location
    Culver City, CA
    MS-Off Ver
    OpenOffice Calc
    Posts
    1

    Re: SUM below - until the next non-blank cell

    Hello,

    I know this is an old thread, but I am trying to recreate this exact scenario in OpenOffice Calc. I know there are some differences between the two programs, (for example Calc doesn't have IFERROR function), but I am trying to break down the logic so I can recreate it, and was wondering if you could explain the bold portion of the formula below:

    =IFERROR(IF(ISTEXT(A2),SUM(B2:INDEX(B2:B100, MATCH(1, 1/ISTEXT(A3:A101),0))),""),SUM(B2:B100))

+ 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: 3
    Last Post: 01-23-2014, 12:19 PM
  2. [SOLVED] Cell referenced in formula has no information displayed (shows blank), return blank cell
    By nunayobinezz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2013, 04:51 PM
  3. If cell blank OR another cell blank then show blank, if not display value
    By stevop622 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-09-2013, 04:07 AM
  4. [SOLVED] 1 or blank cell pulls exact text or leaves cell blank
    By sharpmel in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-30-2012, 12:20 PM
  5. [SOLVED] If one cell contains #, & other cell is blank, show message & require blank be resolved
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-19-2012, 02:23 PM

Tags for this Thread

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