jakeman
Active Member
- Joined
- Apr 29, 2008
- Messages
- 325
- Office Version
- 365
- Platform
- Windows
Hello everyone - I grabbed some code from another site on how to set all pivotitems = false except two items I want to display. It seems like it should be straightforward but I keep getting the following error:
Here is the VBA code I am using:
I am using VBA 7.0 on Excel 2010. Also, the code is failing on the "For Each oPI" line.
Thanks.
Code:
Run-time error '438': Object doesn't support this property or method
Here is the VBA code I am using:
Code:
Sub hidepivotitems()
'
'
Dim oPI As PivotItem
For Each oPI In ActiveSheet.PivotTables("PivotTable2").PivotFields("User")
Select Case oPI.Name
Case "Smith, Joe", "Black, Joe"
Case Else
oPI.Visible = False
End Select
Next oPI
End Sub
I am using VBA 7.0 on Excel 2010. Also, the code is failing on the "For Each oPI" line.
Thanks.