Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to protect pivot table in Excel?

In Excel, how could we protect the pivot table to prevent other users dragging the fields or messing up the layout? This article, I will talk about some methods to protect the pivot table in worksheet.

Protect pivot table with VBA code

Protect pivot table but allow access to the slicer

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

arrow blue right bubble Protect pivot table with VBA code

The following VBA code can help you to protect the pivot table, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: protect pivot table

Sub RestrictPivotTable()
'Updateby Extendoffice 20161026
Dim xpf As PivotField
Application.ScreenUpdating = False
With ActiveSheet.PivotTables(1)
  .EnableDrilldown = False
  .EnableFieldList = False
  .EnableFieldDialog = False
  .PivotCache.EnableRefresh = False
  For Each xpf In .PageFields
    With pf
      .DragToPage = False
      .DragToRow = False
      .DragToColumn = False
      .DragToData = False
      .DragToHide = False
    End With
  Next xpf
End With
Application.ScreenUpdating = False
    MsgBox "The pivot table has been protected!", vbInformation, "Kutools for Excel"
End Sub

3. Then press F5 key to run this code, and a prompt box will pop out to remind you the pivot table has been protected, see screenshot:

doc protect pivot table 1

Notes:

1. This code will disable many of the features in a pivot table, such as preventing users from dragging any of the fields to a different location, and disabling the Field List, Field Settings, Drilldown, and the Refresh feature.

2. If there are multiple pivot tables in active sheet, this code is only applied to the last pivot table.


arrow blue right bubble Protect pivot table but allow access to the slicer

Sometimes, you may want to protect the pivot table but allowing access to the slicer for applying the filter function, the following steps can do you a favor.

1. After inserting the slicer, then right click it, and choose Size and Properties from the context menu, see screenshot:

doc protect pivot table 2

2. In the Format Slicer pane, click Properties to expand the options, and then uncheck Locked option, see screenshot:

doc protect pivot table 3

3. Then close the pane, and then click Review > Protect Sheet to protect this sheet, see screenshot:

doc protect pivot table 4

4. In the popped out Protect Sheet dialog box, then check Select unlocked cells and Use PivotTable & PivotChart options only in the Allow all users of this worksheet to list box, and then enter the password and confirm it, see screenshot:

doc protect pivot table 5

5. Then click OK button to close the dialogs, and now, when you click the pivot table report and try to change it, it will not be modified, but you can apply the Slicer feature as you need.


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Flomaster · 3 months ago
    For Each xpf In .PageFields
    With pf

    а где "х" потеряли?))) должно же быть With xpf
  • To post as a guest, your comment is unpublished.
    andrew · 5 months ago
    The macro doesn't work it just throws an object error
    • To post as a guest, your comment is unpublished.
      skyyang · 4 months ago
      Hi, andrew,
      The code works well, after applying the code, you will get the prompt box to remind you the pivot table has been protected, and then close it, now, when changing any data in the pivot table, a warning message box will be pop out.