From a previous post...
There's no reason to toggle protection when you reset protection when
the file is first opened. Make sure you set 'UserInterfaceOnly:=True'
so your code can modify the sheet but the user can't via the UI. Make
sure your code includes 'AllowFiltering:=True' OR set
'worksheet.EnableAutoFilter:=True'...
Dim wks As Variant
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect <password
wks.Protect Password:=<password, UserInterfaceOnly:=True, _
AllowFiltering:=True '//add more as req'd
Next 'wks
It's feasible, however, that not all sheets need/are protected in a
file so you may want to use a string constant of delimited sheetnames
that protection is applied to...
Const sSheetsToProtect$ = "Sheet1,Sheet2,Sheet4"
Dim vName As Variant
For Each wks In Split(sSheetsToProtect$, ",")
Sheets(vName).Unprotect <password
Sheets(vName).Protect Password:=<password, _
UserInterfaceOnly:=True, _
AllowFiltering:=True '//add more as req'd
Next 'wks
HTH
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion