Hey guys, can you please help me with this simple problem?
I wanna know why this code is not working with all pivot tables in the file, and how can i make it work.
It is a code to block all pivot tables and hide the wizard.
Thanks!
This is the zipped file:
https://drive.google.com/file/d/1eeJy2YeUtMphYKJZ1z_qGvElxLah1Gvt/view?usp=sharing
This is the code:
I wanna know why this code is not working with all pivot tables in the file, and how can i make it work.
It is a code to block all pivot tables and hide the wizard.
Thanks!
This is the zipped file:
https://drive.google.com/file/d/1eeJy2YeUtMphYKJZ1z_qGvElxLah1Gvt/view?usp=sharing
This is the code:
Code:
Sub Inactive()
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
End Sub
Sub BLOCK()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
With ActiveSheet.PivotTables(1)
.EnableWizard = False
.EnableDrilldown = False
.EnableFieldList = False
.EnableFieldDialog = False
.ShowPivotTableFieldList = False
.PivotCache.EnableRefresh = False
For Each pf In .PivotFields
With pf
.DragToPage = False
.DragToRow = False
.DragToColumn = False
.DragToData = False
.DragToHide = False
End With
Next pf
End With
End Sub
Sub UNBLOCK()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
With ActiveSheet.PivotTables(1)
.EnableWizard = True
.EnableDrilldown = True
.EnableFieldList = True
.EnableFieldDialog = True
.PivotCache.EnableRefresh = True
For Each pf In .PivotFields
With pf
.DragToPage = True
.DragToRow = True
.DragToColumn = True
.DragToData = True
.DragToHide = True
End With
Next pf
End With
End Sub
Sub active()
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 = True
Next pf
End Sub
Last edited: