ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to protect and unprotect multiple worksheets effeciently (https://www.excelbanter.com/excel-discussion-misc-queries/132046-how-protect-unprotect-multiple-worksheets-effeciently.html)

Sumknight

How to protect and unprotect multiple worksheets effeciently
 
In Excel 2003, I am trying to protect up to 20 worksheets in one workbook. I
then need to unprotect them to edit each sheet, then protect them again to
prevent editing. I spend half my life protecting and unprotecting! How may I
do this more effeciently?

Jim Thomlinson

How to protect and unprotect multiple worksheets effeciently
 
Try something like this...

Sub ProtectAll()
Dim wks as worksheet

On error Resume Next
for each wks in Worksheets
wks.Protect Password:="tada"
next wks
On error Goto 0
end sub

Sub UnprotectAll()
Dim wks as worksheet

On error Resume Next
for each wks in Worksheets
wks.Unprotect Password:="tada"
next wks
On error Goto 0
end sub
--
HTH...

Jim Thomlinson


"Sumknight" wrote:

In Excel 2003, I am trying to protect up to 20 worksheets in one workbook. I
then need to unprotect them to edit each sheet, then protect them again to
prevent editing. I spend half my life protecting and unprotecting! How may I
do this more effeciently?


Paul B

How to protect and unprotect multiple worksheets effeciently
 
SumKnight, you can use a macro like this,

Sub Protect_All_Sheets()

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

ws.Protect password:="123"

Next ws

End Sub



Sub Unprotect_All_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect password:="123"
Next ws
End Sub


To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is at the top-left of the spreadsheet this will
open the VBA editor, in Project Explorer click on your workbook name, if you
don't see it press CTRL + r to open the Project Explorer, then go to insert,
module, and paste the code in the window that opens on the right hand side,
press Alt and Q to close this window and go back to your workbook and press
alt and F8, this will bring up a box to pick the Macro from, click on the
Macro name to run it. If you are using excel 2000 or newer you may have to
change the macro security settings to get the macro to run. To change the
security settings go to tools, macro, security, security level and set it to
medium


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"Sumknight" wrote in message
...
In Excel 2003, I am trying to protect up to 20 worksheets in one workbook.
I
then need to unprotect them to edit each sheet, then protect them again to
prevent editing. I spend half my life protecting and unprotecting! How
may I
do this more effeciently?




Sumknight

How to protect and unprotect multiple worksheets effeciently
 
Thanks for the quick and useful response. I have already implemented your
technique and am saving time.



"Jim Thomlinson" wrote:

Try something like this...

Sub ProtectAll()
Dim wks as worksheet

On error Resume Next
for each wks in Worksheets
wks.Protect Password:="tada"
next wks
On error Goto 0
end sub

Sub UnprotectAll()
Dim wks as worksheet

On error Resume Next
for each wks in Worksheets
wks.Unprotect Password:="tada"
next wks
On error Goto 0
end sub
--
HTH...

Jim Thomlinson


"Sumknight" wrote:

In Excel 2003, I am trying to protect up to 20 worksheets in one workbook. I
then need to unprotect them to edit each sheet, then protect them again to
prevent editing. I spend half my life protecting and unprotecting! How may I
do this more effeciently?


Sumknight

How to protect and unprotect multiple worksheets effeciently
 
Thank you so much for the perfect answer! I am saving hours at my work
beginning today, and looking so smart!

Mike Smith
(SumKnight)

"Paul B" wrote:

SumKnight, you can use a macro like this,

Sub Protect_All_Sheets()

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

ws.Protect password:="123"

Next ws

End Sub



Sub Unprotect_All_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect password:="123"
Next ws
End Sub


To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is at the top-left of the spreadsheet this will
open the VBA editor, in Project Explorer click on your workbook name, if you
don't see it press CTRL + r to open the Project Explorer, then go to insert,
module, and paste the code in the window that opens on the right hand side,
press Alt and Q to close this window and go back to your workbook and press
alt and F8, this will bring up a box to pick the Macro from, click on the
Macro name to run it. If you are using excel 2000 or newer you may have to
change the macro security settings to get the macro to run. To change the
security settings go to tools, macro, security, security level and set it to
medium


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"Sumknight" wrote in message
...
In Excel 2003, I am trying to protect up to 20 worksheets in one workbook.
I
then need to unprotect them to edit each sheet, then protect them again to
prevent editing. I spend half my life protecting and unprotecting! How
may I
do this more effeciently?






All times are GMT +1. The time now is 09:46 PM.

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