+ Reply to Thread
Results 1 to 27 of 27

Multiple Subtotaling (Subtotal the subtotals and grand total it all)

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi,
    Sql query spits out data onto worksheet, which I then format through VBA for end user
    Columns:
    Manager Name
    Office Name
    client id
    client name
    Billable (gets subtotaled)
    Progress (gets subtotaled)
    Net (gets subtotaled)
    Reserve (is manually entered, gets subtotaled)
    Group (new column to group on)

    Report has only 1 manager name for all data
    Multiple offices, sorted by office
    I have it set up to split out each office group and subtotal it

    Now they also want to subtotal within each office by the new Group column.
    I can figure out how to split out the groups and to subtotal the little groups, but not how to then subtotal the whole group

    Plus they want to add a grand total at the bottom, not sure how to sum that up either.

    I'm kind of lost on how to do all these different subtotals

    Can't use a pivot table because end user has to enter some numbers manually.
    Could maybe use a pivot table, and then somehow convert it to regular worksheet?

    Any ideas, pointers, guidance, or help of any sort would be appreciated.

    ADDED:
    Perhaps sum the whole office set and then somehow remove the little group subtotal numbers - that row will have "subtotal" in col A (has to be formulas due to manual entry)
    Last edited by ker9; 11-30-2010 at 04:04 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    I've used many different approaches to adding subtotals but invariably, I find the approach depends on the structure of the worksheet.

    If you can post a mock-up of your workbook with the same structure as your actual file and with the code you currently use, it'll be helpful.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    I've attached a sample workbook of the raw data and the ultimate final look
    What I need help with is getting the subtotals or running totals

    I need the subtotal of each Office and each group within each office
    Something like
    Office = first office, officetotal = 0
    group = first group, group total = 0
    then some kind of loop that checks to see if the office or the group has changed

    I've been playing with it, but just can't get it to work

    3 sheets - Data sheet is the sheet to mess around with
    RawData is the data (copy and paste over Data sheet)
    Final is what they want it to look like

    I can do the formatting, I just can't quite figure out how to get the different totals, plus 3 columns are manual entry by end user, after data is formatted, and those subtotals need formulas (not hard coded)
    Thanks in advance for any guidance!

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    I see no file attached. Please try again.

    John

  5. #5
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Sorry! The file was too large but I didn't notice the message. I had to delete some stuff to make it fit, but I think it will still be good enough to understand.
    Thank you for any assistance!
    Attached Files Attached Files

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    It would really help if I can see your existing code that you're using to manipulate the data. Otherwise, I'll need to write all the code from scratch. If you've done it already, I'd rather not reinvent the wheel.

    In the attached, should I assume "Data" is the result of this
    Sql query spits out data onto worksheet
    Should I assume that
    end user has to enter some numbers manually
    in "Data" and NOT in final?

    If the file is too large, zip it.

    John

  7. #7
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi
    Data is where the SQL statement puts the data and where the end user will eventually enter the manual numbers.

    Final was just to show what they hoped it would look like

    Nothing I've done comes close to working.

    I've just started trying to use a helper column that would indicate each office change and another helper column (N & O) to indicate each group change. Thinking to count up # of rows for each group and and create formula with that info on an inserted blank line below each group.

    If I can get that part, then the next would be to find each office change and add up the group subtotals.

    I'm a little stuck on counting up and using the row count in a formula.

    One problem is line 32, where office changes but group is same as below so I'm not finding it.

    Do you think this new idea might work?

    I can handle all the formatting, once the summing gets done.

  8. #8
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    This code tells me where things change
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    This code inserts a blank line each time group (or office) changes (change column # to 3 from 13 for office)

    Please Login or Register  to view this content.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    Bear with me while I try to get an understanding of your data.

    As I understand it, the user will make manual entries to "Data" sheet. After these manual entires are completed, then "Data" sheet will be manipulated and made to look like "Final" sheet. Is this correct?

    On "Final" sheet, what's the difference between "Group Subtotal" and "Group Total"? In your sample data, the two amounts are the same or am I missing something?

    What's the significance of "ManualNumber" on "Final Sheet"? These fields are blank (except for fill color).

    John

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    Another question comes to mind. Will the user be inserting new rows or only filling in/changing data in existing rows?

    John

  12. #12
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi, please ask all the questions you want - I'm so glad to have you helping!
    The formatting, summing, inserting of rows, etc. should happen before the user sees the data so they see final product.

    User will not enter rows, only data. User has option to enter data in columns I, J, L and also in the row labeled Manual Number (which would be instead of entering by client above in I, J, L). So Group Total would add in that manual number if used, otherwise, it will be same as subtotal.

    All other columns/rows/cells will be locked.

    If you could just help me figure out how to sum the groups and then how to sum the offices, I think I can get in all the other formatting, extra rows, etc. I'm just totally stuck on getting the subtotals of each group, each office and then a grand total at the bottom.
    Thank you VERY MUCH!

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Ker9

    I think I understand. So the user will make changes to "Final" sheet.

    What does your SQL code look like?
    Where does it reside?
    Is "Data" sheet reused or is a new "Data" sheet created each time the SQL is run?

    I'm certainly not expert on SQL code but I'd like to look at what you're using. It seems to me that if you want the user to see the final product, the data manipulation will need to be married to the SQL code.

    I'll work on the data manipulation as a stand alone for the moment so as to get some ideas on an approach.

    Let me play with it for a while.

    John

  14. #14
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi, John,

    No, Final was just to show what it might look like in the end. Final won't really exist at all.

    Everything happens on Data.

    There is a command button that user clicks to retrieve the data. The SQL code pulls the data onto the Data worksheet, just like you see it in my sample. Then it gets manipulated from there.

    Thanks,
    Karin

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    I understand. For purposes of testing, "Final" will exist. The code will be changed to manipulate "Data" directly when all is working as you require.

    But, to follow up..."Data" IS reused?

    John

  16. #16
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    They will re-run this every month. Data sheet will be completely cleared, the query run again, the formatting all re-done (as there may be more or less data than prior month). It will format automatically by calling any subroutines setup for formatting/subtotaling, etc. before user sees anything.

    Code should be made to work on Data as Final will never really exist. We just hope Data will look like Final (approximately) when all coding is done.

    I can do all the formatting, I just can't figure out how to get subtotals formulas.

    If you can help me get a line after each group labeled Group Subtotal and the (dyanmic) formulas on it, and then a line after each Office, labeled Office Subtotals with (dynamic) formulas and, hopefully, a line at the end labeled Grand Totals with dynamic totals (total of each office subtotal), that would be awesome.

    Using helper columns, or whatever it takes to get there. I've been struggling with this for 4 days.

    Thank you!

  17. #17
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    I did finally get this to work - find the change and sums up

    Please Login or Register  to view this content.

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    I think we can get this to work to satisfy your needs. I'll work on it.

    John

  19. #19
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi, John,
    Do you mean that Data sheet or the Data itself? (A bit confusing)
    If you mean the actual data (not sheet), I'm not sure what you mean by reused.

    Also, I've gotten a little further than I ever have before. I'd like to attach it but it's larger than I'm allowed. Is there any way around that?

  20. #20
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    I removed the final sheet to shrink size of file.
    Run the subs in order and you'll see where I'm at.

    I think I don't have a clue how to subtotal the offices from that point.

    Perhaps this is not the best way to handle this, but...

    Thanks!

    I'll be back tomorrow, I have to go now
    Attached Files Attached Files

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    Regarding this
    Do you mean that Data sheet or the Data itself?
    I meant Data Sheet; I'd assume Data Sheet is cleared of all contents then new SQL data written to it for each new SQL import of data. But, I don't know that.

    Regarding this
    Also, I've gotten a little further than I ever have before. I'd like to attach it but it's larger than I'm allowed. Is there any way around that?
    Create a zip file to reduce the size of the file then post the zip file. On my end, I'll unzip the file and can work with your complete workbook.

    By the way, you're profile shows Excel 2007. Does this need to run JUST in Excel 2007 or does it need to run in earlier versions?

    I've some ideas to resolve your issue.

    John

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    Working on it. I've Children and Grandchildren coming in tomorrow so Holiday issues may interfere for a short while.

    Get back to you ASAP.

    John

  23. #23
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi, John,

    I meant Data Sheet; I'd assume Data Sheet is cleared of all contents then new SQL data written to it for each new SQL import of data. But, I don't know that.
    Yes, data sheet is completely cleared when it's re-run.

    By the way, you're profile shows Excel 2007. Does this need to run JUST in Excel 2007 or does it need to run in earlier versions?
    It has to run on 2003, nothing earlier.

    Have a wonderful holiday with your family!

    Thank you for any assistance!

    Karin

  24. #24
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Please see this link - it's interesting code and it works, but I'm not sure how I might translate it to fix my problem
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=115

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    The attached appears to do as you requested. I've checked some of the numbers but not all. I've not done any formatting. If you need help with the same, let me know.

    The code was developed in Excel 2000 so this issue should be OK
    It has to run on 2003, nothing earlier
    Let me know of issues.

    John

    PS: I looked at the link you provided. Although one may not recognize it, the code uses very similar procedures.
    Attached Files Attached Files
    Last edited by jaslake; 11-23-2010 at 05:14 PM. Reason: Add PS

  26. #26
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    John, this is FABULOUS!
    I'm amazed - thank you so much!!!
    I will test it more, but it seems to be working.
    I can't possibly thank you enough for helping me with this.

    Karin

  27. #27
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Multiple Subtotaling (Subtotal the subtotals and grand total it all)

    Hi Karin

    It's been my pleasure. I enjoy working on projects that makes one's work life simpler...and easier. Please do test thoroughly...as I indicated, I tested some of the numbers but not all.

    If you need further help or find issues let me know. If the solution works for you, please mark your post as solved. A click on the scales is always appreciated.

    John

+ 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