Protect/Unprotect Multiple Worksheets

G

Guest

I used the following macro from an earlier posting to protect multiple
worksheets in a workbook and it worked great. (Thank you Kevin Backmann!!!)

Now I would like a macro to do the reverse - that is unprotect all
worksheets. I tried the same macro changing every instance of the word
Protect to Unprotect, but that didn't work. What can I do to make this work?

Thanks. (I've copied and pasted Kevin's earlier posting below:)

-------------------------------------------

"The following macro cycless through all the worksheets in the active
workbook, protecting them and assigning the password of "Password"

Sub ProtectAll()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
ws.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True, _
Password:="Password"
Next ws

Set wb = Nothing
Set ws = Nothing

End Sub

Place it in a VBA module by pressing Alt+F11, click INSERT on the menu and
select MODULE. You can either type the code above or cut and paste it. To
run the macro select TOOLS on the menu, click MACRO and then select MACROS.
The macro will be in the list of available macros. You can select it and
then click the RUN command button."
 
A

Ardus Petus

'--------------------------
Sub unprotectall()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
ws.Unprotect _
Password:="Password"
Next ws

Set wb = Nothing
Set ws = Nothing

End Sub
'-------------------------------

HTH
 
G

Guest

Thank you!

Ardus Petus said:
'--------------------------
Sub unprotectall()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
ws.Unprotect _
Password:="Password"
Next ws

Set wb = Nothing
Set ws = Nothing

End Sub
'-------------------------------

HTH
 

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