CubeField.CreatePivotFields method (Excel)

The CreatePivotFields method enables users to apply a filter to PivotFields not yet added to the PivotTable by creating the corresponding PivotField object.

Syntax

expression.CreatePivotFields

expression A variable that represents a CubeField object.

Remarks

In OLAP PivotTables, PivotFields don't 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

Sub FilterFieldBeforeAddingItToPivotTable() 
 ActiveSheet.PivotTables("PivotTable1").CubeFields("[Date].[Fiscal]").CreatePivotFields 
 
 ActiveSheet.PivotTables("PivotTable1").PivotFields("[Date].[Fiscal].[Fiscal Year]").VisibleItemsList = 
 
 "[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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.