Fix Excel AutoFilter and Sort Disappearing in Protected Worksheets
Question details
AutoFilter and Sort options periodically disappear in a protected, macro-enabled workbook, requiring the user to repeatedly unprotect and reconfigure the settings.

- 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.
Ensure you have the worksheet protection password and the necessary permissions to view and edit the background VBA macro code in the Developer tab.
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.
Press ALT + F11 on your keyboard to launch the Microsoft Visual Basic for Applications editor.
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.
Modify the protect line to explicitly allow sorting and filtering. Change it to: ActiveSheet.Protect Password:="yourpassword", AllowSorting:=True, AllowFiltering:=True
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.

Manually Re-enable Filter and Sort Options
If the issue is not caused by an active macro reset, double-check that the worksheet protection settings are being configured correctly when applied manually.
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.

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.




