excel - VBA: How do I allow filters to be turned on and off on a protected sheet? -


i have following piece of code, removes filters , re-applies them selected cells:

range("a10:am10").select  selection.autofilter selection.autofilter 

the problem have when sheet protected , try run code errors, there way of allowing filters turned on , off on protected sheet?

how you?

it depend on setup of protection. when protect worksheet, there option allow filtering (autofilter).

if you're 1 who's protecting sheet, can use of worksheet's protect method's parameters set protection options. here protect method's parameters:

sheetname.protect(password, drawingobjects, contents, scenarios, userinterfaceonly, allowformattingcells, allowformattingcolumns, allowformattingrows, allowinsertingcolumns, allowinsertingrows, allowinsertinghyperlinks, allowdeletingcolumns, allowdeletingrows, allowsorting, allowfiltering, allowusingpivottables) 

if want able implement filters code, can set userinterfaceonly parameter true. protection block users changes. code changes allowed.

sheetname.protect userinterfaceonly:=true 

or, if want allow users filter contents of worksheet interface, set allowfiltering parameter true userinterfaceonly parameter.

sheetname.protect userinterfaceonly:=true, allowfiltering:=true 

your code should work both options.

hope helps!


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -