VBA with PivotTables

MPFraser7

New Member
Joined
Dec 14, 2016
Messages
34
I have two workbooks, each containing a pivot table. The two pivot tables contain the same fields, but the values are different. What I'm trying to do is use VBA to add Fields to "Rows", one at a time. So let's say the pivot tables have 5 fields: Dollars, Account, Activity, Category, Category 2. I would manually put Dollars in "Values" and Account in "Columns" and I'm not looking to automate this part. Starting with the 3rd field, Activity, I want to bring it in the "Rows" using VBA. When I'm done with that field, I want to use VBA to bring the next one in the list which would be Category. Preferably this code would skip over fields that are already brought in the report, so it would skip over Dollars and Account if they were sorted after Category, for example. The vba would do it for the two pivot tables. The goal of this is to facilitate reconciling the values of two pivot tables in two separate workbooks. If it's easier, I could put the pivot tables in the same workbook, in different sheets. I'm looking forward to hearing your suggestions.
Workbook NameSheet NamePivotTable Name
ProductionSheet1PivotTable1
TestingSheet1PivotTable1

<tbody>
</tbody>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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