Name

pivottable.Format(Format)

Synopsis

Applies an autoformat to the pivot table.

Argument

Settings

Format

An xlPivotFormatType constant indicating the autoformat to apply. Can be one of these settings: xlPTNone, xlPTClassic, xlReport1 to xlReport10, xlTable1 to xlTable10.

The following code applies an autoformat to a pivot table on the active worksheet:

Sub ApplyAutoFormat(  )
    Dim pt As PivotTable
    ' Run CreateOLAPPivotTable to create this pivot table.
    Set pt = ActiveSheet.PivotTables(1)
    ' Apply format
     pt.Format xlReport1
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.