pivot table formatting automation

miconian

Well-known Member
Joined
Aug 18, 2004
Messages
769
I have a large workbook with a pivot table on every worksheet. The pivot tables are very similar to each other, and for the most part use the same fields, they just have different data selected.

The problem: I have to go through the entire thing and add fill color to certain fields, in order to make all the pivot tables easier to read. The fill color has to be consistent across the workbook.

I really don't want to do this manually. Is there some way that I can just do the fill color in one pivot table, and then create some code that loops through the workbook and applies that same fill color formatting to all the other pivot tables?

I tried to record a macro of myself adding fill color in one case, but the code that came back includes data that I did not mean to record (despite using relative references):

Code:
PivotFormat()
'
'PivotFormat
'
    ActiveSheet.PivotTables("PivotTable12").PivotSelect _
        "'Sold To Customer'[All;Total] Jones", xlDataAndLabel, True
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent5
        .TintAndShade = 0.599993896298105
        .PatternTintAndShade = 0
    End With
End Sub

All I wanted to do was to format the row with the row label "sold to customer" as .TintAndShade = 0.599993896298105. But somehow the name of the pivot table (PivotTable12) and the value selected for the report filter (Jones) ended up in the code, and I'm not sure how to get them out of there, because they don't apply to all the other pivot tables that I want to format.

Thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,433
Messages
6,124,863
Members
449,195
Latest member
MoonDancer

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