+ Reply to Thread
Results 1 to 11 of 11

Macro -- Copying Pivot Table and Changing Row Labels

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Macro -- Copying Pivot Table and Changing Row Labels

    Hola! Using Excel 2007 on Windows 7 64 bit. Familiar with using macros, but no idea how to write my own VBA -- only make very minor edits to existing code.

    I attempted to record a macro to copy a pivot table with many row labels, multiple times on the same sheet. I then want to remove all but one Row Label, then repeat until I had individual tables with only one row label each. The issue is that this macro refers to each pivot table by its name statically (PivotTable148) and does not work when moving to a new sheet. How can I reference them dynamically?

    Example code from my recorded macro below. I need the bold items to be updated dynamically. Or a totally new way to approach this Please and thank you! I'd be happy to PayPal a cup of coffee to anyone who can help! I'll need to do this regularly in my new position.

    Please Login or Register  to view this content.
    Last edited by andcarro; 12-04-2013 at 08:33 AM.

  2. #2
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    Bump --- any help deeply appreciated.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    Perhaps you can try:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    Thank you very much for your response. I'll give it a shot!

  5. #5
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    I get the message [RUN TIME ERROR '1004': "PasteSpecial method of Worksheet Class failed) with this being the problem line:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    Is it same error using the original version instead:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    It is, unfortunately :/

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    Is I2 empty?

  9. #9
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    It is. However excel will paste the first table before giving me the error.

  10. #10
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    If the first table is pasted I am not seeing how the line returns an error? Is it possible to provide a workbook for review?

  11. #11
    Registered User
    Join Date
    07-31-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro -- Copying Pivot Table and Changing Row Labels

    I'll try and get something with false data tomorrow. Thank you again for all of your help.

+ 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. [SOLVED] Changing dates in a Pivot Table using a Macro
    By peter_caswell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2012, 02:58 AM
  2. Replies: 0
    Last Post: 07-03-2012, 11:09 AM
  3. Replies: 6
    Last Post: 03-19-2012, 04:50 AM
  4. Excel 2007 : macro for changing pivot table criteria
    By sawyerjames in forum Excel General
    Replies: 0
    Last Post: 08-31-2011, 07:44 AM
  5. [SOLVED] changing Pivot table name via macro
    By Sandip in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2006, 11: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