Use autofilter with macro in a protected sheet

M

Minos

Hi,

I have a protected worksheet with the option of “Use Autofilter†enabled.
I have a macro that runs a filter for selected records. I have a second macro
(see below) that removes the previous filter.

ActiveSheet.Unprotect
Selection.AutoFilter Field:=20
ActiveSheet.Protect

End Sub

How can I again enable the “Use Autofilter†together with the “Active
Sheet.Protect†command.

Thanks

Minos
 
L

Luke M

Change the last line to callout what you want to allow. The standard
protection protects drawing objects, contents, and scenarios. We'll just add
on that you want to allow filtering.

ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top