Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default 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?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect/unprotect ALL worksheets in workbook ? Newsgal Excel Discussion (Misc queries) 5 May 4th 10 06:20 PM
Protect/Unprotect Multiple Worksheets Katherine R Excel Discussion (Misc queries) 2 May 9th 06 04:07 PM
unprotect/protect grouped worksheets in excel mcwhirter Setting up and Configuration of Excel 1 August 8th 05 01:21 AM
How to protect and unprotect 30 worksheets in a file every month . Protect & Unprotect Several Worksheets Excel Worksheet Functions 4 January 10th 05 01:29 PM
Protect/unprotect all worksheets Janna Excel Worksheet Functions 2 January 7th 05 01:01 AM


All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"