+ Reply to Thread
Results 1 to 4 of 4

Copy Pivot into Table - - headers going into Table body

  1. #1
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Question Copy Pivot into Table - - headers going into Table body

    Hi,

    I need to copy a Pivot Table into an existing table. I have just about got everything working however, the copied range of the pivot table needs to be pasted into the Column headers of my table. That is "shifted by 1 row up". Does anyone perhaps have an eloquent way of doing this?

    Q03 Copy pivot into table with VBA.xlsm

    Capture.PNG

    Thanks in advance,
    Michelle

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Copy Pivot into Table - - headers going into Table body

    You can define your pivot data area as a named dynamic name and copy it into the excel table area.

    Here his the definition for the named range: Pivot_Data =OFFSET(Sheet1!$G$7,0,0,COUNTA(Sheet1!$G:$G)-2,3)

    I also included some code to clear out old data in a pivot table. It's one of my "standard" modules, so I just imported it.
    Attached Files Attached Files

  3. #3
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Lightbulb Re: Copy Pivot into Table - - headers going into Table body

    Quote Originally Posted by dflak View Post
    You can define your pivot data area as a named dynamic name and copy it into the excel table area
    Hi Dflak, thank-you for taking the time to send me a solution. Unfortunately I could not get your spreadsheet working - the OFFSET function kept returning an error. So I continued with my own solutions. (thank-you though)

    SOLUTION 1
    Q03 Copy pivot into table.Solution_01.xlsm
    PivotTable1 is pasted into Table2
    -Table2 must exist before paste
    -All Table2 rows/cols are deleted
    -PivotTable1 is then pasted into Table2
    -The headers are in the correct place(my original problem)

    SOLUTION 2
    Q03 Copy pivot into table.Solution_02.xlsm
    Matching columns of PivotTable1 are pasted into Table2
    -Table2 must exist before paste
    -If Table2 has matching column name, then PivotTable1 values are pasted in to those matching columns
    -All other Table2 columns are unaffected
    Last edited by michellepace; 12-15-2015 at 04:20 AM. Reason: Added second soluition

  4. #4
    Registered User
    Join Date
    01-10-2014
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Copy Pivot into Table - - headers going into Table body

    Hi this is something I'm trying to leverage into my own file. Is there a way to expand the copy paste function to include headers created if I include a field under Columns in the pivot table. I basically have months broken into columns in my data. Take for instance in your Solution 2 in the pivot table if i were to drag the Profit field under Columns. Thanks

+ 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. Pivot Table Data to Column Headers
    By danielex in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-05-2015, 02:39 PM
  2. Identify table, Get Pivot, Copy the pivot table to new consolidated Sheet
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2013, 04:09 AM
  3. [SOLVED] Database headers as Row objects in Pivot Table
    By Nairobi Nice in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 02-14-2013, 08:37 AM
  4. Changing the name of cell headers in the pivot table
    By SEMMatt in forum Excel General
    Replies: 2
    Last Post: 09-01-2011, 03:03 PM
  5. pivot table column headers
    By jrtaylor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-11-2009, 09:23 AM
  6. [SOLVED] ? Pivot Table from 3 columns of raw data with headers
    By William Elerding in forum Excel General
    Replies: 2
    Last Post: 04-03-2006, 08:15 AM
  7. [SOLVED] Pivot table - colour of headers
    By eeelllaaa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2005, 07:06 PM

Tags for this Thread

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