VBA to protect worksheet but allowing AutoFilter on locked cells

dellzy

Board Regular
Joined
Apr 24, 2013
Messages
146
Hi Experts,

I have a table with headers. I locked the cells that contain headers (apart from all other cells I need to protect). I have some macros to allow the users to filter the data based on the selection in a dropdown list. The macros should first unprotect the worksheet and do whatever coded then unprotect back the worksheet BUT allowing the autofilter on the lockedcells (headers). I notice that when I manually protect the worksheet and manually select option to allow AutoFilter, the filter works on locked cells but it won't work when I apply by coding. I've googled and referred to all similar issues and the solutions always recommend the below code:-

ActiveSheet.Protect AllowFiltering:=True, Password:="abc1234##"

however, the above code doesn't work as how it works when selecting and protecting manually. Did I miss anythg? Appreciate some help as I've been trying this for hours already but still fail. :(

Thank you in advance.

DZ
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
So very sorry to all the viewers and those who are trying to solve my issue. I have found the cause why it was not working by code. It's totally my own careless mistakes. I've parked the code to allow autofiltering in other sub module rather than into the right module! no wonder it was not working earlier!! i've parked correctly and it works!

So sorry for wasting anyone's time on this. Please ignore this thread. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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