+ Reply to Thread
Results 1 to 8 of 8

VBA to group totals of each category within each date range

  1. #1
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    VBA to group totals of each category within each date range

    I know this can be accomplished with a pivot table. However, there will be different people doing this task each day who cannot grasp the concept of a pivot table. So this has to be an automated process through VBA to prevent human errors.

    The data is on a spreadsheet named SUMMARY.
    The data was filtered in ascending order by Date (column G) then by Category (column F).

    What I need help with, is to create a matrix for each date that will indicate the total amount for each category within that date.
    The only criteria for totaling any category is whether or not an X is placed in column E (the 'EACH' header)
    Column D can be ignored at this time (but not deleted)

    This spreadsheet is never more than 100 rows, so looping through the rows is OK, unless someone could do this with filtering. I don't know how to do either, and I looked for hours to find a method. I need help on this one. So, I hope someone can assist me.

    Here's an idea I have about the desired layout result, but maybe someone has a better layout idea.

    1-Dec
    BLACK 30
    BROWN 21
    BLUE 5
    GOLD 44
    GREEN 21
    RED 25

    2-Dec
    BROWN 43
    GOLD 25
    RED 27

    3-Dec
    BLACK 4
    BROWN 40
    GREEN 10
    RED 36

    The file is attached below, and the desired result is also on the Summary sheet. However, it does not need to be there. It can be on a separate sheet.
    Thank you for looking at this.
    Attached Files Attached Files
    Last edited by Jim885; 08-29-2015 at 03:22 PM. Reason: added file
    If I helped in any way, please click the star

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to group totals of each category within each date range

    What about a Pivot table and a macro to refresh it: See attached
    Attached Files Attached Files
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: VBA to group totals of each category within each date range

    Thanks PCI, I didn't know pivot tables could be refreshed with a macro.
    That's good to know.

    The only concern I have with this approach is that this report will not be used by me, or anyone else that knows how to create pivot tables. So, I can't be inserting pivot tables each time this report is run, nor train someone else to do it because no one else knows Excel beyond using it as a data entry log. That is why I need this part to be done at the click of a button. Because that's about all anyone else in my company can do.

    I was able to find the code below that is close to what I need. However, the code counts the number of instances that the products' name appears in column F and puts the result in column R.
    If this code could be enhanced to add the quantities from column C every time an 'X' appears in column E, that would be perfect.

    Thanks,
    Please Login or Register  to view this content.

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA to group totals of each category within each date range

    Maybe :

    Please Login or Register  to view this content.

    Regards

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to group totals of each category within each date range

    See your macro with ajustment
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: VBA to group totals of each category within each date range

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: VBA to group totals of each category within each date range

    karedog, PCI, jindon,

    Each of you provided the perfect solution for what I need.

    Thank you all. This is much appreciated. Each of you are a genius!

    Reps have been provided to each of you.



    PCI,
    Your ability to modify the code I found, and make it work for my purposes, is exceptional. That will help me see and understand the logic of the code.
    I spent a whole day trying to modify that code, before I asked for this help.

    Again, to each of you ... Thank you so much.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA to group totals of each category within each date range

    Hi Jim885,
    Thank you for your thanks.
    It is a pleasure to know that you spent time to try, be free to ask for explanation.
    Now if you want to progress in the use on the Scripting Dictionary, no doubt Jindon's code is smarter
    PCI

+ 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. Category Totals Using Lists
    By Liberty42 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-17-2013, 09:34 PM
  2. [SOLVED] How do I group daily totals into weekly/monthly/quarterly totals
    By situationroom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-28-2013, 09:58 AM
  3. Pivot Table -- Category Grand Totals
    By Tyler.Primecp in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-14-2012, 01:33 PM
  4. [SOLVED] SUM TOTALS IF CATEGORY equals to defined values
    By lemuel in forum Excel General
    Replies: 5
    Last Post: 04-24-2012, 11:52 AM
  5. Single field fits fault category, event category determined by group of faults
    By SchoobsVT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-07-2010, 08:51 AM
  6. Totals - how can I group values to give totals?
    By nickm84 in forum Excel General
    Replies: 2
    Last Post: 01-01-2010, 01:58 PM
  7. [SOLVED] Adding category totals
    By [email protected] in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-15-2006, 06:50 PM
  8. Find category value based on date range?
    By thewiz1972 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-09-2006, 10:35 PM

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