Hi, I am trying to remove a data field from an excel pivot table, using access vba:
Here is the part of the code concerned:
Select Case NbOfCols
Case 3
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col3").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col4"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col5"), "All Projects In Process", xlSum
End If
Case 4
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col4").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col5"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col6"), "All Projects In Process", xlSum
End If
Case 6
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col6").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col7"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col8"), "All Projects In Process", xlSum
End If
End Select
As soon as it hits the first line with the "xlHidden", it does not perform it, and jumps to the "End Select" statement. Any clue?
Thank you.
Here is the part of the code concerned:
Select Case NbOfCols
Case 3
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col3").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col4"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col5"), "All Projects In Process", xlSum
End If
Case 4
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col4").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col5"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col6"), "All Projects In Process", xlSum
End If
Case 6
.ActiveSheet.PivotTables(MyTabID).PivotFields("Col6").Orientation = xlHidden
If MyCategory = "PM" Then
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col7"), "All Projects In Process", xlSum
Else
.ActiveSheet.PivotTables(MyTabID).AddDataField ActiveSheet.PivotTables( _
MyTabID).PivotFields("Col8"), "All Projects In Process", xlSum
End If
End Select
As soon as it hits the first line with the "xlHidden", it does not perform it, and jumps to the "End Select" statement. Any clue?
Thank you.