vba advanced filter (protected sheet)

tony567

Well-known Member
Joined
Aug 23, 2008
Messages
515
i have problem when try to advanced filter data in another sheet that is protected

I am using the macro in sheet that also protected too

i try to use:

Sheets("Report").Unprotect ""
Sheets("Database").Unprotect ""
'Advanced Filter Code
Sheets("Database").protect ""
Sheets("Report").protect ""


it say runtime error 1004 "you can not use this command i protected sheet"


thank you
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The disadvantages of using .Unprotect and then a password is that 1) you have to put the password directly into the code and 2) the worksheet will be temporarily unprotected and it will remain unprotected if the macro is interrupted.

A better solution is to use UserInterfaceOnly:=true which will allow the macro to make changes to a protected sheet.

Try:
Code:
Sheets("Report").UnProtect UserInterfaceOnly:=True
Sheets("Database").UnProtect UserInterfaceOnly:=True

your Advanced Filter macros...

Sheets("Report").UnProtect UserInterfaceOnly:=False
Sheets("Database").UnProtect UserInterfaceOnly:=False
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,988
Members
449,093
Latest member
Mr Hughes

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