+ Reply to Thread
Results 1 to 8 of 8

Create Pivot Table with group dates; summarize values by average; h:mm

  1. #1
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Create Pivot Table with group dates; summarize values by average; h:mm

    I'm way over my head when it comes to creating pivot tables in vba.

    Attached data. Each week through the month this report is run and all the worksheets (31) are combined to a sheet named Combined.
    I need this worksheet to create a pivot table onto a sheet named Pivot
    Dates need to be grouped by month
    Both Aux columns are sum by average and formatted by h:mm

    The attached has a sample graphic of what the final should look like. (We copy\paste this data into another data set for a dashboard)

    As always thanks for your assistance as I plod along endeavoring to learn.
    Jim
    Attached Files Attached Files

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    If I understand this correctly, you have created a pivot table just fine, (IE:Sample Worksheet). You just need help on creating a macro that will do the same thing. If this is correct, then the easiest way is turn on the macro recorder and go through the steps and then turn off the macro recorder. This will give you your macro, Sort of. It will NOT be dynamic, which means if your row count changes then you have to adjust it. This can be done using VBA. If you need help with that part and where to insert the "LastRow" variable, just let me know. Here is what I recorded....

    have fun

    Please Login or Register  to view this content.
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    I tried that - the challenge comes in with it woun't recognise the pivot name as that can change - i.e your "PivotTable2"
    Here is my code - you can see it says "PivotTable4" - also the end row could change so would be interested in your solution
    Please Login or Register  to view this content.

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    right, makes sense...So this may help....

    I added the LR variable and plugged it in

    I also "set" the pivot table name to something I/We know and then I use that reference while working with the pivot table.

    I don't have data to test this but it should work, unless I missed changing a "PivotTable 4" to PTName

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    Your solution put me onto a couple things. I added a couple declarations to the macro and changed all the "PivotTable4" to "MyPT" - i also had it clear the Pivot page of any pivots if they existed. I also changed the "Combined!R1C1:R246C6" to "Combined!R1C1:R500C6" to accommodate the change in rows (Is this the solution you were referring to?
    Here is the code that seems to be working quite well.
    Please Login or Register  to view this content.

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    excellent -- compare it to my code....looks like you are heading in the right direction...

  7. #7
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    Had a couple problems running your still with the name - not all got replaced - but added your LR code and works like a charm - really appreciate your time helping.
    Jim

  8. #8
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Create Pivot Table with group dates; summarize values by average; h:mm

    I figured I missed a couple....sorry about that part...anyway....glad I could help and great job modifying the code....have a great day....

    Thanks for the Rep Points
    Last edited by judgeh59; 07-24-2015 at 11:23 AM.

+ 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. Group dates in pivot table
    By murthigvs in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 03-17-2015, 02:14 PM
  2. Group dates in a pivot table slicer
    By lora2014 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-02-2014, 01:25 AM
  3. how to create group in pivot table data
    By ganeshadeshpande in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-18-2013, 04:33 AM
  4. Pivot Group Dates - how to remove start and end dates from table
    By markoloughlin in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-21-2012, 04:19 AM
  5. Replies: 10
    Last Post: 07-05-2012, 03:37 PM
  6. [SOLVED] Pivot table group dates
    By RD Wirr in forum Excel General
    Replies: 3
    Last Post: 07-22-2006, 03:10 PM
  7. Group Dates in Pivot Table
    By tufmarkerr in forum Excel General
    Replies: 0
    Last Post: 04-23-2006, 03:42 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