VBA Protect sheets but allow sorting/filtering

SilencioDubueno

New Member
Joined
May 26, 2022
Messages
4
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello All!
I'm currently writing out a sub to protect specific sheets such that they can still be accessed and edited by macros, but people can still go and filter/sort the data tables freely. My understanding is this code should work:

VBA Code:
VBA Code:
Worksheets("Sheet1").protect Password:="", UserInterfaceonly:=True, AllowSorting:=True, AllowFiltering:=True

The sheet is protected with this and can be edited by macros ald lets people filter, but will not allow people to sort data. When I run the code for another page that has a specific Edit Range, the code states that the macros on it cannot be run. I'm not 100% sure why there is a difference with the same code.

Any help is appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
When selecting "Protect Sheet"

1660030433385.png
 
Upvote 0

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top