VBA for copying a pivot table

whiteevo4

Board Regular
Joined
May 12, 2010
Messages
77
Hello everyone,

I was wondering if you could help me. I wanted a VBA code that can help me with the following.
- Copy a a pivot table (I have multiple pivot tables on the 1 worksheet so I want to be able to select which one).
- Paste this to a selected workbook called 'Data' worksheet 'Sheet1' on my C: drive. (This has to be paste value as this is a CSV file).

If this is possible any help would be great.

Thanks.

Dominic.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Have you tried recording a macro doing it?

You can always post back your resulting code for someone to clean up.
 
Upvote 0
Hi Smitty, I forgot to mention. I haven't done VBA before so I wouldn't know when to start or end. THis will help me in understanding how to write code.

Cheers.
 
Upvote 0
No problem,

To start recording a macro you can use keystrokes ALT+T+M+R, or go through the Developer tab (which isn't shown in Excel 2007+, so you need to go to File-->Options-->Customize Ribbon and check the Developer tab in the right pane). You can also click the macro button at the bottom left of the Excel status bar (next to the "Ready" notice).

Then do your thing with selecting the Pivot Table in question and copy/pasting it to your destination workbook. You can stop recording with ALT+L+R, the Developer tab or clicking the status bar button.

To see the code when you're done you can hit ALT+F11, which will open the VBE (Visual Basic Editor). Look in the Project Explorer on the left-hand side of the VBE window for "Module1", open it and you'll see your recorded code, which you can post back here. (If you don't see the Project Explorer displayed just hit CTRL+R).

I'll be scarce next week as I'm onsite on a project in LA, but there are plenty of people around to help out, and I'll check back when I can.


Good luck, and don't get frustrated! :)
 
Upvote 0
Recording a macro is the best place to start. If you post the code back here someone can help clean it up for you.
 
Upvote 0

Forum statistics

Threads
1,213,564
Messages
6,114,334
Members
448,567
Latest member
Kuldeep90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top