ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect/Unprotect Multiple Worksheets (https://www.excelbanter.com/excel-discussion-misc-queries/87624-protect-unprotect-multiple-worksheets.html)

Katherine R

Protect/Unprotect Multiple Worksheets
 
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."


Ardus Petus

Protect/Unprotect Multiple Worksheets
 
'--------------------------
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
--
AP

"Katherine R" a écrit dans le message
de news: ...
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."




Katherine R

Protect/Unprotect Multiple Worksheets
 
Thank you!

"Ardus Petus" wrote:

'--------------------------
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
--
AP

"Katherine R" a écrit dans le message
de news: ...
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."






All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com