Writing VBA code to use Auto Filter while in a Protected Sheet or Protected Workbook

passin through

New Member
Joined
Apr 25, 2015
Messages
8
Is it possible to protect a sheet and/or workbook and assign a macro to a button which will Filter on and off the predetermined rows while the sheet is protected? When the sheet is unprotected, the macro runs exactly as desired.

On the Protect Sheet tab I have the SORT and AutoFilter boxes checked.

Currently using the following code:

ActiveSheet.Range("BCD_SORT_COLUMNS").AutoFilter Field:=2

When the routine is run, it halts and gives the following error message:

Run-time error ‘1004’:
You cannot use this command on a protected sheet. To use this command, you must first unprotect the sheet (Review tab, Changes group, Unprotect Sheet button). You may be prompted for a password.


The cells set up to use the FILTER are shown in the Advanced Filter dialog box as follows:
List range: $B$9:$C$301
Criteria range: $B$10:$FD$298
The cells named "BCD_SORT_COLUMNS" are $B$9:$C$301
 
Thanks again. That was just the information needed.
To make it work, I needed to add :)=1) or :)=True) after the item,
heck, I didn't know...
Thanks for your help, much appreciated!!
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

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