Pivot Table Formatting - Excel 2003

ajay_gajree

Well-known Member
Joined
Jul 16, 2011
Messages
518
Good morning,

I am having issues formatting a Pivot Table, I have formatted a table with borders, colours etc, but on the next day when new data is added and the table is refreshed the formatting does not carry through to the next day.

How can I format a Pivot Table so that the formatting is for all cells even when criteria is amended?

Thanks and regards

Ajay Gajree
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
When a pivot table is refreshed, any manually applied formatting is removed.

You can use this code to select various parts of the Pivot Table.

Code:
Sub SelectPivotTableParts()
    Dim bHasPageRangeField As Boolean
    Dim bHasColumnRangeField As Boolean
    Dim bHasRowRangeField As Boolean
    Dim bHasDataRangeField As Boolean
 
    Dim lX As Long
 
    With ActiveSheet.PivotTables(1)
        For lX = 1 To .PivotFields.Count
            If .PivotFields(lX).Orientation = xlPageField Then bHasPageRangeField = True
            If .PivotFields(lX).Orientation = xlRowField Then bHasRowRangeField = True
            If .PivotFields(lX).Orientation = xlColumnField Then bHasColumnRangeField = True
            If .PivotFields(lX).Orientation = xlDataField Then bHasDataRangeField = True
        Next
 
        .TableRange1.Select
        MsgBox "TableRange1"
 
        .TableRange2.Select
        MsgBox "TableRange2"
 
        If bHasPageRangeField Then
            .PageRange.Select
            MsgBox "PageRange"
        End If
 
        If bHasRowRangeField Then
            .RowRange.Select
            MsgBox "RowRange"
        End If
 
        If bHasColumnRangeField Then
            .ColumnRange.Select
            MsgBox "ColumnRange"
        End If
 
        If bHasDataRangeField Then
            .DataBodyRange.Select
            MsgBox "DataBodyRange"
        End If
 
        If bHasDataRangeField Or bHasColumnRangeField Or bHasRowRangeField Then
            .DataLabelRange.Select
            MsgBox "DataLabelRange"
 
            For lX = 1 To ActiveSheet.PivotTables(1).VisibleFields.Count
 
                .VisibleFields(lX).DataRange.Select
                MsgBox "Visible Field " & lX & " (" & .VisibleFields(lX).Name & ") Data Range "
 
                .VisibleFields(lX).LabelRange.Select
                MsgBox "Visible Field " & lX & " (" & .VisibleFields(lX).Name & " Label Range "
 
            Next
        End If
 
    End With
End Sub

If you are using Excel 2007 or later, you can apply a format to the pivot table that will be maintained through pivot table updates.

Otherwise (or in addition) you can to adapt the above code to apply desired formatting when triggered by the worksheet PivotTableUpdate event.
 
Upvote 0

Forum statistics

Threads
1,224,530
Messages
6,179,373
Members
452,907
Latest member
Roland Deschain

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