gruntingmonkey
Active Member
- Joined
- Mar 6, 2008
- Messages
- 444
- Office Version
- 365
- Platform
- Windows
Having an issue where I'm trying to remove a series of numbers via a loop from a pivot table but its not working when I use a variable as opposed to a direct number/letters. I get the error "Unable to get the PivotItems property of the PivotField class" on the line that starts with ".PivotItems(....."
I'm sure I've left something really simple out but can't figure it out currently.
Code that doesnt work
Code that does work (but only for 1 variable and I need to go through many)
I'm sure I've left something really simple out but can't figure it out currently.
Code that doesnt work
VBA Code:
Sub test3()
ANum = 2226
With Sheets("Working Out").PivotTables("PivotTable1").PivotFields("report_id")
.PivotItems(ANum).Visible = False
End With
End Sub
Code that does work (but only for 1 variable and I need to go through many)
VBA Code:
Sub test3()
With Sheets("Working Out").PivotTables("PivotTable1").PivotFields("report_id")
.PivotItems("2226").Visible = False
End With
End Sub