Sheet protection does not work as expected when clicking macro button

Excelquestion35

Board Regular
Joined
Nov 29, 2021
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hello,

For a project I require to protect some of the cells in my document, however it is not working as the way it should be.
I protect the sheet by selecting the cells that I want to lock and then protect the sheet in the following way.


1676983399601.png




My sheet has some macro buttons that require code to unlock the sheet before it runs the code and later protects the sheet with a password.
That code I put inside all macro buttons that I have.

Yet, as soon as I use one of the macro buttons I am not able to use the filter buttons to filter on the columns for instance. (On those columns I did not specifically put a protection and even allowed to use autofilter).
Adjusting any cell values is possible.

My only goal is to prevent people from adjusting certain cells, but other than that the document should be able to be used freely.
What am I doing wrong in order to get the result I want?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
In your macros when you protect the sheet, you'll need to specify the applicable allowable items. For example:

ActiveSheet.protect Password:="password here",AllowFiltering:=True
 
Upvote 0
Solution

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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