Formatting Pivot Tables on Multiple Worksheets

SAMCRO2014

Board Regular
Joined
Sep 3, 2015
Messages
158
I have 17 worksheets (by manager) with one pivot table per worksheet filtered to data to suit each manager's needs. All the headings are the same on each pivot table. There must be a way to format all the pivot tables the same way at the same time or via a loop but I can't figure it out. I tried recording it and got a whole bunch of coding which is making my macro too long and it will not run.

Any ideas? I was thinking along the lines:

For each PivotTable on the Worksheet
PivotTable. Activate
Insert format coding here
Next Worksheet

Can this be done?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Re: Formatting Pivot Tables on Mutiple Worksheets

Hi there, you can try doing something like this:

Code:
For Each ws In ActiveWorkbook.Worksheets
    For Each pt In ws.PivotTables
        'Insert format code here
    Next pt
Next ws


If each value field should be the same format, you can add in
Code:
For Each df In pt.DataFields
 
Upvote 0
Re: Formatting Pivot Tables on Mutiple Worksheets

So which sheet has the Pivot table style you want copied to all other sheets
Would it be Sheet(1)
So you want sheets 2 to the last sheet in your workbook to have the same Pivot Table format as Pivot table on Sheets(1)
Is that true?

Then use this script:

Code:
Sub Format_Pivot_Table()
'Modified  10/19/2018  10:07:30 AM  EDT
Application.ScreenUpdating = False
Dim ans As String
Dim i As Long
ans = Sheets(1).PivotTables(1).TableStyle2
    For i = 2 To Sheets.Count
        Sheets(i).PivotTables(1).TableStyle2 = ans
    Next
Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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