Unprotect Sheets

K

Karen

Is there a way to unprotect a series of worksheets?
All of the worksheets have the same password.
When I group the worksheets and go to Tools > Protection,
the "Unprotect Sheet" opeion is grayed out.

Thank you
 
F

Frank Kabel

Hi
try

sub unprotect_all()
dim wks as worksheet
on error resume next
for each wks in activeworkbook.worksheets
wks.unprotect
next
end sub

If you have a password applied change
wks.unprotect
to
wks.unprotect password:="your password"
 
K

Karen

Thank you - I'll give it a try
-----Original Message-----
Hi
try

sub unprotect_all()
dim wks as worksheet
on error resume next
for each wks in activeworkbook.worksheets
wks.unprotect
next
end sub

If you have a password applied change
wks.unprotect
to
wks.unprotect password:="your password"

--
Regards
Frank Kabel
Frankfurt, Germany



.
 
A

Adam

Hi Karen,
I had the very same problem some time back and got an excellent VBA code
from Harald staff that you can find below. You have one sub that protects all
the worksheets with the same password and one that unlocks all the sheets
with the same PW.

-------------------
Hi

Not without macro code. Here it is:

Sub LockEm()
Dim i As Long
Dim PW As String
Dim WS As Worksheet
PW = InputBox("Password:")
On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Protect (PW)
Next
MsgBox i & " errors while protecting", vbInformation
Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub

Sub UnLockEm()
Dim i As Long
Dim PW As String
Dim WS As Worksheet
PW = InputBox("Password:")
On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Unprotect (PW)
Next
MsgBox i & " errors while unprotecting", vbInformation
Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub


"Karen" skrev:
 

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

Top