Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CubeField.CreatePivotFields Method

Office 2007
The CreatePivotFields method is new in Microsoft Office Excel 2007. It enables users to apply a filter to PivotFields not yet added to the PivotTable by creating the corresponding PivotField object.

Version Information
 Version Added:  Excel 2007

Syntax

expression.CreatePivotFields

expression   A variable that represents a CubeField object.

Remarks

In OLAP PivotTables, PivotFields do not exist until the corresponding CubeField is added to the PivotTable. The CreatePivotFields method enables users to create all PivotFields of a CubeField. Users can also add filters to the PivotFields and set properties on them before the CubeField is added to the PivotTable.

Example

Visual Basic for Applications
Sub FilterFieldBeforeAddingItToPivotTable()
    ActiveSheet.PivotTables("PivotTable1").CubeFields("[Date].[Fiscal]").CreatePivotFields

     ActiveSheet.PivotTables("PivotTable1").PivotFields("[Date].[Fiscal].[Fiscal Year]").VisibleItemsList =

        Array("[Date].[Fiscal].[Fiscal Year].&[2003]", "[Date].[Fiscal].[Fiscal Year].&[2004]", "[Date].[Fiscal].[Fiscal Year].&[2005]")

    ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "[Date].[Fiscal].[Fiscal Semester]").VisibleItemsList = Array("")

    ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "[Date].[Fiscal].[Fiscal Quarter]").VisibleItemsList = Array("")

    ActiveSheet.PivotTables("PivotTable1").PivotFields("[Date].[Fiscal].[Month]"). _
        VisibleItemsList = Array("")

    ActiveSheet.PivotTables("PivotTable1").PivotFields("[Date].[Fiscal].[Date]"). _
        VisibleItemsList = Array("")
End Sub



Community Additions

Show: