antaeusguy
Board Regular
- Joined
- Mar 8, 2010
- Messages
- 81
Hi all,
I'm using a Pivot Table which is generated from OLAP. Certain fields are multi-dimension and can be "drilled down".
For example, the field "Customer" has "[Customer].[Customer group]" i.e. from Customer Group it can be drilled down to Customer.
I wish to create a macro that can filter a single entry.
I tried this code to choose the customer group AA - HAPPY HUISDIER
Sub Choose_Pivot()
With ActiveCell.PivotTable.PivotFields("[Customer].[Customer Group]")
For i = 1 To .PivotItems.Count
If Not .PivotItems(i).Name Like "AA - HAPPY HUISDIER" Then
.PivotItems(i).Visible = False
End If
Next i
End With
End Sub
When I run it, it stops where the red code above is. It gives the error message:
Run-time error '1004':
Unable to set the visible property of the PivotItem class.
But if I try this similiar code on a normal pivot table (not from OLAP), it works:
Sub Choose_Pivot()
With ActiveCell.PivotTable.PivotFields("Name")
For i = 1 To .PivotItems.Count
If Not .PivotItems(i).Name Like "Paul van Rijn" Then
.PivotItems(i).Visible = False
End If
Next i
End With
End Sub
Can anyone give me some guidance on solving this problem? Many thanks
I'm using a Pivot Table which is generated from OLAP. Certain fields are multi-dimension and can be "drilled down".
For example, the field "Customer" has "[Customer].[Customer group]" i.e. from Customer Group it can be drilled down to Customer.
I wish to create a macro that can filter a single entry.
I tried this code to choose the customer group AA - HAPPY HUISDIER
Sub Choose_Pivot()
With ActiveCell.PivotTable.PivotFields("[Customer].[Customer Group]")
For i = 1 To .PivotItems.Count
If Not .PivotItems(i).Name Like "AA - HAPPY HUISDIER" Then
.PivotItems(i).Visible = False
End If
Next i
End With
End Sub
When I run it, it stops where the red code above is. It gives the error message:
Run-time error '1004':
Unable to set the visible property of the PivotItem class.
But if I try this similiar code on a normal pivot table (not from OLAP), it works:
Sub Choose_Pivot()
With ActiveCell.PivotTable.PivotFields("Name")
For i = 1 To .PivotItems.Count
If Not .PivotItems(i).Name Like "Paul van Rijn" Then
.PivotItems(i).Visible = False
End If
Next i
End With
End Sub
Can anyone give me some guidance on solving this problem? Many thanks