View Single Post
  #5   Report Post  
Javier
 
Posts: n/a
Default

Thanks Arno, it works!!

Regards

"arno" wrote:

Hi Javier,

Thanks Arno. My version is Excel 2000. Sorry but I execute both lines
before protecting the sheet and it doens´t work. Can you help me?


you have an error in your code. I use the following code to protect and
unprotect all my sheets:

Sub protectmysheets()
With Application
.EnableCancelKey = xlDisabled
.ScreenUpdating = False
End With

'enable outlining and filter
For i = 1 To ActiveWorkbook.Sheets.Count
Sheets(i).EnableOutlining = True
Sheets(i).EnableAutoFilter = True
Next

'blablabla whatsoever i do here

'protect sheets
For Each blattl In ActiveWorkbook.Sheets
blattl.Protect "mysecretpassword", True, True, True, True
Next
Sheets(1).Select
End Sub

and to unprotect:
Sub unprotectmysheets()
With Application
.EnableCancelKey = xlDisabled
.ScreenUpdating = False
End With
For Each blattl In ActiveWorkbook.Sheets
With blattl
.Unprotect "mysecretpassword"
.Visible = True
.ScrollArea = ""
End With
Next
End Sub

regards

arno