+ Reply to Thread
Results 1 to 9 of 9

Subtotal range above blank rows, subtotal in the last row adjacent right column

  1. #1
    Registered User
    Join Date
    06-05-2012
    Location
    Afton, OK USA
    MS-Off Ver
    2007
    Posts
    8

    Subtotal range above blank rows, subtotal in the last row adjacent right column

    Hello people of excel!

    I am brand new to the forum. Brand new to VBA and moderate in Excel in general. Here's my problem:

    I have thousands of rows of data for account transactions. Once the rows are sorted by account #, I need to separate each account with a blank space. Also I need to subtotal each account, BUT I need my subtotal to be located in the adjacent right column of the last value for each account. For example:

    Account Description Amount Account Total
    0001 Screws $1000 $1000

    0002 Hammers $1000
    0002 Hammers $1000 $2000

    0003 Bolts $1000
    0003 Bolts $1000
    0003 Bolts $1000 $3000

    I appreciate any help you can give.

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

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Adding the subtotals in an adjacent column is easy and requires no VBA. In C2 put this formula and copy down:

    =IF(COUNTIF($A$2:$A2, $A2)=COUNTIF($A:$A, $A2), SUMIF($A:$A, $A2, $B:$B), "")


    This isn't the programming forum, so VBA isn't the normal solutions offered here. What is the purpose of the blank rows? Truly needed? These subtotals are plenty obvious once added with the formula above.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    06-05-2012
    Location
    Afton, OK USA
    MS-Off Ver
    2007
    Posts
    8

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Thanks JB I don't know when I need VBA or just a basic formula at this point. The blank rows are required, not sure why but boss says they are. If the spreadsheet was formatted differently I could just subtotal everything but it isnt possible with the current format. I need the formula to skip the blank row and sum the next account, repeated about 5000 times.

  4. #4
    Registered User
    Join Date
    06-05-2012
    Location
    Afton, OK USA
    MS-Off Ver
    2007
    Posts
    8

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Ok JB the formula worked, however it is placing zero subtotals next to each blank cell and I need it to omit that zero. How do I do that?

  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: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Copy the formula from the post above, it should not be putting zeros in blank cells, that formula should be blank in those cells.

    If you continue to have the zeros, post the workbook and I'll see what the problem is.

  6. #6
    Registered User
    Join Date
    06-05-2012
    Location
    Afton, OK USA
    MS-Off Ver
    2007
    Posts
    8

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Still struggling with this. Any help is welcome. I cannot post the workbook due to the nature of the info.

    ---------- Post added at 03:44 PM ---------- Previous post was at 03:05 PM ----------

    Here is a sample workbook of the desired effect, before and after.

    Please Login or Register  to view this content.
    Example of data with desired effects. (Column Headings are the same)
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-30-2012 at 08:17 PM.

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

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    This is the exact same formula, just summing column G instead of column B, and it does not put zeros in... put this H2, then copy down:

    =IF(COUNTIF($A$2:$A2,$A2)=COUNTIF($A:$A,$A2), SUMIF($A:$A, $A2, $G:$G), "")


    If your column A is going to have blanks here and there, THAT would be a problem, so use this in that case:

    =IF($A2="", "", IF(COUNTIF($A$2:$A2,$A2)=COUNTIF($A:$A,$A2), SUMIF($A:$A, $A2,$G:$G ), ""))

  8. #8
    Registered User
    Join Date
    06-05-2012
    Location
    Afton, OK USA
    MS-Off Ver
    2007
    Posts
    8

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    The second formula works great, if you manually insert rows. This is helpful but i need the formula to insert whole blank rows in between projects. This seems to just subtotal to the right. The main concern is the inserting of blank rows, the subtotalling is secondary.

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

    Re: Subtotal range above blank rows, subtotal in the last row adjacent right column

    Well, there's no formula that can insert rows. That's a manual process, or a VBA project for the programming forum.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-31-2012 at 09:44 AM.

+ 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