Protect an Excel worksheet using VBA but allow everyone to select slicers and sort columns

Copper Contributor

How can you in VBA protect an Excel worksheet while allowing users to select slicers and sort columns but keep the headers locked? 


I have to set the Contents to False in the worksheet Protect method, so the users can select the slicers. However, this does not protect my headers. If I set Contents to True in the Protect method, the headers are locked, but you cannot select any slicers.

Any help will be greatly appreciated. Thank you!

1 Reply
Solved thru the following steps:
1. Protect the worksheet.
2. Unprotect the worksheet.
3. Add Allow Edit Range.
4. Protect the worksheet again.