Multiple pivot tables on the same sheet

Woftae

New Member
Joined
Feb 10, 2018
Messages
16
To my fellow custodians of the free world.
Any help on this issue would be appreciated, and many thanks in advance.

I had a sheet with a single pivot table on it (PivotTable1) and I had a macro that would copy the data from this pivot table (PivotTable1) onto another sheet as values only which would then be saved as a PDF which worked fine.
I then added another pivot table (PivotTable10) to the same sheet, to provide additional information, visually only and was not required to be copied etc.
Now when I run the same macro that was copying the data from pivot table (PivotTable1) it's referencing the newly added pivot table (PivotTable10) and I cant get it to reference and copy the data from pivot table (PivotTable1) as it used to.

the section of code that I have narrowed it down top is as follows;

Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables(1)
PT.TableRange1.Select
MsgBox Worksheets("Pivot for Suppliers").PivotTables(1).Name
Selection.Copy
Sheets("Order for Supplier").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You can specify the name rather than the index:

Rich (BB code):
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables("PivotTable1")
PT.TableRange1.Copy
With Sheets("Order for Supplier").Range("A7")
   .PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
   .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
 
Upvote 0
Solution
Hi Rory,
Thank you so much, it worked a treat and your solution was elegant as well.
You are a legend among champions.
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,987
Members
449,093
Latest member
Mr Hughes

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