Closed Thread
Results 1 to 9 of 9

Nested subtotals macro

  1. #1
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Nested subtotals macro

    Hi

    I have a table of data - see first sheet of the attached file as an example (the 'Data' sheet) - I need to sort and subtotal this data by two different columns. The result I'm trying to obtain can be seen on the second sheet of the file. In other words, I need to create subtotals for one column within the subtotal of another column - best to look at the file example to see what i mean.

    Appreciate any help with this.

    John
    Attached Files Attached Files

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Nested subtotals macro

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Nested subtotals macro

    Hi Bob

    Thanks for this - however, it didn't work as required.

    A couple of problems:
    - one of the groupings didn't get subtotalled (see attached - highlighted in yellow).

    - the nesting hasn't come out as required - one layer missing (see comparison with second sheet).

    Also, i need to be able to adapt this macro to a larger table of data which has many more columns, where columns B & C would be located in columns D & K respectively in a table with data in columns A-T.

    I'm hoping this isn't too difficult - I tried adjusting the column coding in your macro but the macro only subtotalled by column D.

    Appreciate your help again if poss.

    Cheers
    John
    Attached Files Attached Files

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Nested subtotals macro

    When I run it that layer is not missing, I get DEF Costs.

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Nested subtotals macro

    I see, you want the subtotals in a different order and must have changed the code for that. It needs further mod

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Nested subtotals macro

    Hi Bob

    for some reason this is not working on my pc.

    It seems to work for the first half of the data, but then it goes a bit funny after that.

    Not quite sure what your For next loops are doing - can you explain?

    Ta
    John

  7. #7
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Nested subtotals macro

    It seems to work fine for me.

    The first loop goes through and recalculates all of the subtotal ranges, the second then goes and deletes all of the reeptitions of the subtotals in column B.

  8. #8
    Registered User
    Join Date
    02-09-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Nested subtotals macro

    Dear Bob

    Your macro did work very well with the file you guys were working on. I tried to apply that macro on my file (attached) and changed the macro accordinlgy but it didn't work. Could you please help me. I need the result of subtotal using macro as in the attached file

    Thanks

    Zahid
    Attached Files Attached Files

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Nested subtotals macro

    Zahid,

    Welcome to the board, however, please note

    Your post does not comply with Rule 2 of our Forum RULES.

    Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

Closed 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