View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Sumknight Sumknight is offline
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?