VBA & Macro Problems

How to Protect an Excel Worksheet While Allowing Slicers and Sorting

Elise WilliamsElise Williams Nov 11, 2026 869 views

Question details

The user needs to protect an Excel worksheet to prevent changes to headers, but still allow users to click slicers and sort data columns.

How to Protect an Excel Worksheet While Allowing Slicers and Sorting
Product
Excel
Device & OS
not provided
Scenario
Securing the structural integrity of a worksheet (like headers) while retaining data interactivity via slicers and sorting capabilities.
Observed behavior
By default, protecting a worksheet locks all interactions, preventing users from filtering with slicers or sorting data unless specific permissions and ranges are configured.
Before you start

Before applying protection, ensure your slicers are already inserted into the worksheet and identify the exact cell ranges where sorting needs to be permitted.

Solution 1Recommended

Configure Allow Edit Ranges and Sheet Protection

Set up specific ranges that allow user interaction and adjust the protection permissions to explicitly enable sorting and PivotTable/slicer usage.

By default, protecting a worksheet locks all interactive elements. To keep slicers and sorting functional while securing your headers, you must explicitly declare editable ranges and grant specific permissions during the protection process.

1
Unprotect the Worksheet

If your worksheet is already protected, navigate to the 'Review' tab on the ribbon and click 'Unprotect Sheet' before making any changes.

2
Add Allow Edit Range

Still on the 'Review' tab, click 'Allow Users to Edit Ranges'. Click 'New', define the specific data range where users need to apply sorting, and click 'OK'.

3
Unlock the Slicer Properties

Right-click the Slicer(s) on your sheet and select 'Size and Properties'. In the formatting pane under 'Properties', uncheck the 'Locked' box to ensure the slicer remains clickable.

4
Protect the Worksheet with Permissions

Click 'Protect Sheet' on the 'Review' tab. In the dialog box that appears, ensure the boxes for 'Sort' and 'Use PivotTable and PivotChart' are checked. Enter an optional password and click 'OK'.

Configure Allow Edit Ranges and Sheet Protection
VBA Implementation: If you are automating this via VBA, you can use the code: ActiveSheet.Protect Password:="yourpassword", AllowSorting:=True, AllowUsingPivotTables:=True.

Protect and Manage Data Interactivity Easily with WPS Spreadsheet

WPS Spreadsheet offers advanced protection features that allow you to secure important headers and formulas while keeping your pivot tables, slicers, and sort functions fully interactive.

  1. 1. Open your Document in WPS: Launch WPS Spreadsheet and open your document. Navigate to the 'Review' tab.
  2. 2. Define Editable Ranges: Click 'Allow Users to Edit Ranges' and select the data area you wish to remain sortable.
  3. 3. Apply Sheet Protection: Click 'Protect Sheet', check the boxes for 'Sort' and 'Use PivotTable and PivotChart' to enable slicers, and confirm.
Free, lightweight, and user-friendly spreadsheet softwareFully compatible with Microsoft Excel (.xlsx) formats and advanced protection settingsIntuitive Review tab to easily manage editable ranges and sheet protectionSeamless migration of VBA macros and worksheet settings
microsoft office alternative - wps office

Frequently Asked Questions

Why is my slicer locked after protecting the sheet?

Slicers are considered PivotTable elements. When protecting the sheet, you must check the 'Use PivotTable and PivotChart' option in the protection dialog to allow users to click and interact with the slicer.

Can I use VBA to automate allowing slicers on a protected sheet?

Yes. You can automate this by adding the parameters AllowUsingPivotTables:=True and AllowSorting:=True to your Worksheet.Protect method in your VBA macro.

How do I unlock specific cells for data entry while the rest of the sheet is protected?

Select the cells you want to unlock, right-click and choose 'Format Cells'. Go to the 'Protection' tab, uncheck the 'Locked' box, and then proceed to protect the sheet from the Review tab.