+ Reply to Thread
Results 1 to 12 of 12

Macro for multiple subtotals

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Macro for multiple subtotals

    Hello, i'm in need of some VBA help for an excel macro. I have a macro that takes data from one sheet and moves the relevant/needed data to a second sheet within the same workbook. Once the data is moved to a new sheet, the macro then separates the data based on the date by putting two lines in between each set of data as shown in the attached picture. What I would like to be able to do is subtotal each little group (generally anywhere between 1 and 3 lines) under the hours which is column J and that's where i'm stuck. I have everything else working properly except I am stumped on how to get column J subtotals for each little group to work. Any help would be greatly appreciated!

    sample.JPG
    Attached Images Attached Images
    Last edited by orlex; 10-26-2015 at 04:45 PM.

  2. #2
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Macro for multiple subtotals

    Hi


    this is how I would have done it... (there may be better ways, im no expert) ... but hope it helps


    Please Login or Register  to view this content.
    If I helped, Don't forget to add to my reputation

  3. #3
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Re: Macro for multiple subtotals

    Unfortunately that didn't work for my case. It actually ended up doing nothing. Any other ideas?

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Macro for multiple subtotals

    any chance you can post an example of the data?

  5. #5
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Re: Macro for multiple subtotals

    Attached are two samples of the sheet that comes out once I get it separated into a second sheet. I need each small group that pertains to whatever date, to have it subtotal below the last row of that group.

    Sample one: This sample has it before I run part of my macro that separates the rows into groups based on the date.

    Sample two: This sample is what happens after the macro has been run to separate the rows into groups based on the date.
    Attached Files Attached Files
    Last edited by orlex; 10-26-2015 at 03:37 PM.

  6. #6
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Macro for multiple subtotals

    in your examples (both) your data is on sheet2. This is why my code did not work.

    I have adjust it it accordingly.

    I have also provide you with one to remove the sub totals we create with the first one... just in case

    I only created this for the "SAMPLE DATA post macro"

    I've tested it, and it workd


    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Macro for multiple subtotals

    Try the attached
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Re: Macro for multiple subtotals

    Thank you Jindon, that worked perfectly.

    I appreciate your effort Steve7913
    Last edited by orlex; 10-26-2015 at 04:08 PM.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Macro for multiple subtotals

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  10. #10
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Re: Macro for multiple subtotals

    Quote Originally Posted by jindon View Post
    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Jindon, I actually I have one final question. Is there a way to make the subtotals bold and if the subtotal is under 8.0, make the subtotal text red?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Macro for multiple subtotals

    Try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Macro for multiple subtotals

    OOps, typo
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.

+ 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. Add Multiple Subtotals
    By pociners in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-25-2014, 05:12 AM
  2. [SOLVED] subtotals with multiple layers
    By plamb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-25-2013, 02:20 PM
  3. Macro to apply subtotals to multiple sheets
    By Scotbot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2012, 09:10 AM
  4. Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. [SOLVED] Subtotals multiple columns
    By Gary L Brown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  6. Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. [SOLVED] Subtotals multiple columns
    By john liem in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

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