ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Use autofilter with macro in a protected sheet (https://www.excelbanter.com/excel-discussion-misc-queries/238845-use-autofilter-macro-protected-sheet.html)

Minos

Use autofilter with macro in a protected sheet
 
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


Luke M

Use autofilter with macro in a protected sheet
 
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
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Minos" wrote:

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



All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com