logo
search
Office Settings & Configuration

Fix Excel AutoFilter and Sort Disappearing in Protected Worksheets

Ayan MasoodAyan Masood Sep 25, 2026 870 views

Question details

AutoFilter and Sort options periodically disappear in a protected, macro-enabled workbook, requiring the user to repeatedly unprotect and reconfigure the settings.

How to Fix Excel AutoFilter and Sort Options Disappearing in a Protected Worksheet
Product
Microsoft Excel
Device & OS
not provided
Scenario
Working with a protected Excel worksheet that runs background VBA macros.
Observed behavior
Even when AutoFilter and Sort are initially enabled during worksheet protection, the features turn off automatically and become unavailable.
Before you start

Ensure you have the worksheet protection password and the necessary permissions to view and edit the background VBA macro code in the Developer tab.

Solution 1Recommended

Modify VBA Macro Protection Parameters

Macros that programmatically unprotect and re-protect worksheets will reset custom permissions to default unless explicitly coded to allow sorting and filtering.

In macro-enabled workbooks, automated scripts often re-apply worksheet protection after executing a task. If the VBA code only calls the basic 'Protect' method, it revokes permissions for features like AutoFilter and Sort. You must add specific parameters to the VBA script to maintain these capabilities.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to launch the Microsoft Visual Basic for Applications editor.

2
Locate the Protection Code

In the Project Explorer pane on the left, find the module or worksheet containing your macro. Look for lines of code using the 'ActiveSheet.Protect' or 'Worksheet.Protect' method.

3
Update the Protection Parameters

Modify the protect line to explicitly allow sorting and filtering. Change it to: ActiveSheet.Protect Password:="yourpassword", AllowSorting:=True, AllowFiltering:=True

4
Save and Test

Save the changes to your macro-enabled workbook, close the VBA editor, and run the macro again to ensure the AutoFilter and Sort options remain active.

Modify VBA Macro Protection Parameters
Microsoft Q&A Help: If your workbook contains highly complex macros and the issue persists, consider posting your specific code scenario in Microsoft Q&A under the Office tag for specialized VBA assistance.
Free Microsoft Office alternative

Try WPS Office for Seamless Spreadsheet Management

If troubleshooting complex macro issues and protection settings in Microsoft Excel is slowing you down, WPS Office offers a streamlined, highly compatible alternative for all your spreadsheet tasks.

Fully compatible with Microsoft Excel formats, including .xlsx and .xlsmIntuitive AutoFilter, Sort, and worksheet protection tools out of the boxFree and lightweight office suite with a familiar user interfaceSeamless migration of your existing protected spreadsheets
microsoft office alternative - wps office

Frequently Asked Questions

Why do sorting and filtering stop working when I protect my Excel sheet?

By default, protecting a worksheet locks all interactions to prevent accidental changes. You must explicitly check the 'Sort' and 'Use AutoFilter' options in the protection dialog before applying the password.

Can a background macro override my manual worksheet protection settings?

Yes. If a macro is programmed to unprotect and re-protect a worksheet, it will apply its own protection settings. Unless the VBA code explicitly includes parameters to allow sorting and filtering, your manual settings will be erased.

Are AutoFilters and worksheet protections supported in WPS Spreadsheets?

Yes, WPS Spreadsheets fully supports AutoFilters, sorting, and worksheet protection. You can apply these features to protected worksheets using the same permission checkboxes available in Microsoft Excel.