+ Reply to Thread
Results 1 to 8 of 8

Summarizing a report

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Thumbs up Summarizing a report

    Hi,
    This thread may be similar to my last thread but I'm gonna ask my question more vividly. I have two types of maintenance activities, Emergency Maintenance (EM) and Preventive Maintenance (PM).
    Each of this maintenance types is done by specific personnel and in a specific date. I want to sum their work time based on maintenance type, the personnel's name, their department, and the date related to that task being done. This can be done more easily using PowerPivot but I want to learn VBA coding. I tried to solve it using Dictionaries in VBA. I used a tutorial and wrote my code but it does not give me my desired result. I provided my desired result in the file below.
    I need to make some changes to my code. I'm new to VBA and I'm not good at dictionaries in VBA. Please give me some code corrections and explanations of each line of your code. I want to learn how your code is working.
    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Summarizing a report

    Hi fa2020,

    Is your expected results EM=26 & PM=18 ? I'm sure you know that this can easily be achieved with SumIf but looks to me you want to learn more about VBA dictionary ... Try the below

    Edit: I just re-read your question & seems you need more details than EM=26 & PM=18 which I found in your file. If this is not your final target, please post what's your expected results look like based on the sample file in post #1

    Please Login or Register  to view this content.
    Last edited by nankw83; 06-28-2020 at 03:33 PM.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2507 Win 11
    Posts
    24,933

    Re: Summarizing a report

    An alternative is to use Power Query/Get and Transform located on the Data Tab. Here is the Mcode from the action.

    Please Login or Register  to view this content.
    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    1
    Date Maintenance Type Department Personnel Name Total Time
    2
    5/12/2020
    EM Mechanical Jennifer
    3
    3
    5/12/2020
    EM Electrical Alex
    8
    4
    5/13/2020
    PM Electrical Alex
    2
    5
    5/13/2020
    PM Mechanical Jennifer
    4
    6
    5/13/2020
    EM Electrical Amanda
    3
    7
    5/13/2020
    EM Mechanical Alex
    7
    8
    5/14/2020
    EM Industrial Engineering Amanda
    5
    9
    5/14/2020
    PM Electrical David
    4
    10
    5/15/2020
    PM Industrial Engineering Amanda
    8
    Sheet: Sheet1

    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps

    M-code basics:
    - "let" is the start of a query
    - "in" is the closing of a query
    - each transformation step sits in between those 2 lines
    - each step line is ended by a comma, except the last one
    - "Source" is always the first step (Source Data)
    - After "in" you have the last step referenced
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Summarizing a report

    Quote Originally Posted by nankw83 View Post
    Hi fa2020,
    Edit: I just re-read your question & seems you need more details than EM=26 & PM=18 which I found in your file. If this is not your final target, please post what's your expected results look like based on the sample file in post #1
    [/code]
    Thank you for response. Yes, I need more details about the personnel activity. I provided an example in the right side. I need the same result using VBA.
    I want to have total work time based on each date. Also, personnel name and their department should be in the final result. My sample desired result at the right of my sheet can tell everything.
    And if it is possible, Please share the SumIfs syntax method in VBA for achieving my desired result too.
    Last edited by fa2020; 06-28-2020 at 11:15 PM.

  5. #5
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Summarizing a report

    Quote Originally Posted by alansidman View Post
    An alternative is to use Power Query/Get and Transform located on the Data Tab.
    I want to do the same work using VBA and Dictionary or SumIfs (in VBA).

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

    Re: Summarizing a report

    Is this how you wanted?
    Please Login or Register  to view this content.
    This would be easier to understand.
    Please Login or Register  to view this content.
    Last edited by jindon; 06-29-2020 at 12:48 AM.

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Summarizing a report

    Quote Originally Posted by fa2020 View Post
    My sample desired result at the right of my sheet can tell everything.
    LOL I guess I need a larger screen laptop, I was only seeing the main table until column L … Apologies, I didn't scroll further to the right to see your desired output in column Q. Anyway, I see that jindon has already provided a working solution

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

    Re: Summarizing a report

    fa2020, thanks for the rep.

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

+ 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. Agging report, openingbalance report,customer report vab code was not working
    By rana19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2015, 03:38 AM
  2. Replies: 4
    Last Post: 08-18-2015, 10:02 AM
  3. [SOLVED] parsing and summarizing a column for dates, then summarizing in a parallel column
    By James C in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2013, 10:02 AM
  4. [SOLVED] Sales Report - Summarizing the totals
    By Ben1985 in forum Excel General
    Replies: 8
    Last Post: 03-19-2013, 05:57 AM
  5. Errors in code for importing production report Workbooks and Summarizing
    By cbsansoy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2012, 02:18 AM
  6. Summarizing Report
    By jokla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-02-2007, 09:44 PM
  7. summarizing
    By SMIKWM in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-28-2007, 06:40 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