Nutterhead
New Member
- Joined
- Apr 25, 2017
- Messages
- 27
Hello,
I am trying to create a VBA code to disable item selection on multiple pivot tables in a workbook. I found the below code online but it only locks one pivot. and I need it to cycle through all the pivots. I tried to change the number to the amount I have but that didn't work. Can someone help me with a better code?
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
Set pt = ActiveSheet.PivotTables(1)
For Each pf In pt.PivotFields
pf.EnableItemSelection = False
Next pf
I am trying to create a VBA code to disable item selection on multiple pivot tables in a workbook. I found the below code online but it only locks one pivot. and I need it to cycle through all the pivots. I tried to change the number to the amount I have but that didn't work. Can someone help me with a better code?
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
Set pt = ActiveSheet.PivotTables(1)
For Each pf In pt.PivotFields
pf.EnableItemSelection = False
Next pf