Restrict
PivotTable
You can use a macro to disable many
of the features in a pivot table. The following code prevents users
from dragging any of the fields to a different location, or off the
pivot table. It also prevents them from using the Pivot Wizard, Field
List, Field Settings, or Drilldown, and disables the Refresh feature.
Note: Instead of .PivotFields,
you can use .RowFields, .ColumnFields or .PageFields
Sub RestrictPivotTable()
Dim pf As PivotField
With ActiveSheet.PivotTables(1)
.EnableWizard = False
.EnableDrilldown = False
.EnableFieldList = False 'Excel 2002+
.EnableFieldDialog = 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
|