Protect / Unprotect Sheets

  • Thread starter Thread starter Rob F
  • Start date Start date
R

Rob F

Hi

Can anyone provide two simple macros to protect all sheets
in a workbook, and the opposite - i.e. unprotect all
sheets?

Ideally, I'd then like to move on to designing a form that
lists all the worksheets that I can toggle protection or
or off from. But first things first!

Thanks

Rob F
 
Hello Rob
Sub Protect()
For Each f In Sheets
f.Protect '("pwd") optional if password
Next f
End Sub

Sub Unprotect()
For Each f In Sheets
f.Unprotect '("pwd") optional if password
Next f
End Sub

HTH
Cordially
Pascal
 
Sub toggleprotect()
With ActiveSheet
If .ProtectContents = True Then
.Unprotect
Else
.Protect
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top