+ Reply to Thread
Results 1 to 5 of 5

How to get a subtotal from a varying number of rows?

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    California, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    How to get a subtotal from a varying number of rows?

    Hi, people.
    If the data looks sorta' like this...

    24 56 54
    12 43 54
    34 65 73
    Subtotal 70 164 181

    2 56 23
    34 76 29
    23 8 63
    34 7 53
    54 2 76
    Subtotal 147 149 244

    43 22 77
    13 6 4
    Subtotal 56 28 81

    There could be from 2 to 20 rows of data between each subtotal row.
    How can I add up the data From AFTER the previous "subtotal" line?

    And then...
    is there a way to get a Grand Total at the bottom,
    just adding up the numbers in the "subtotal" lines?

    Thanks very much.

    Mark53

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: How to get a subtotal from a varying number of rows?

    Please attach a sample workbook with expected output for better understanding


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: How to get a subtotal from a varying number of rows?

    Hi

    Take a look at the attached file.
    Sheet 1 shows how you can use Excel's built in SubTotal feature within Outlines on the Data tab, if you have a criterion upon which to cause the subtotal to appear.
    In the example I have posted there is a change in date, and the graphic on the sheet shows how this was selected in the Subtotal

    On sheet 2, I have create a formula based solution, which depends upon you writing the word Subtotal in column A, at the point where you insert my subtotaling formula

    =SUMPRODUCT(--($A$2:$A4<>"Subtotal"),B$2:B4)-SUMPRODUCT(--($A$2:$A4="Subtotal"),B$2:B4)
    Attached Files Attached Files
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  4. #4
    Registered User
    Join Date
    09-28-2010
    Location
    California, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: How to get a subtotal from a varying number of rows?

    Thanks very much, Roger.
    That SUMPRODUCT thing that you made works Terrifically !

    THANKS.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to get a subtotal from a varying number of rows?

    I've marked this thread as SOLVED for you.
    Next time, select Thread Tools from the links above to mark a thread as SOLVED. Thanks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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