ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Can I protect a range of worksheets in a book with one action? (https://www.excelbanter.com/excel-worksheet-functions/30187-can-i-protect-range-worksheets-book-one-action.html)

Sussex Fran

Can I protect a range of worksheets in a book with one action?
 
If a workbook contains, say 20 worksheets, is there a way of
protecting/unprotecting all the sheets at the same time to avoid going into
each one separately to protect?
Using Office Excel 2003.


Martin

No I don't think so unless you create a macro.
--
Regards,

Martin


"Sussex Fran" wrote:

If a workbook contains, say 20 worksheets, is there a way of
protecting/unprotecting all the sheets at the same time to avoid going into
each one separately to protect?
Using Office Excel 2003.


Jason Morin

Use these 2 macros to protect and unprotect all sheets:

Sub ProtectAllSheets()
Dim ws As Worksheet
Dim strPassWord As String
strPassWord = "apple" '<--- set password here
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:=strPassWord
Next
End Sub

Sub UnprotectAllSheets()
Dim ws As Worksheet
Dim strPassWord As String
strPassWord = "apple" '<--- set password here
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:=strPassWord
Next
End Sub

---
Put the code in a regular/standard module. If you've never worked with
macros before, see:

http://office.microsoft.com/en-us/as...047111033.aspx

and

http://www.mcgimpsey.com/excel/modules.html

HTH
Jason
Atlanta, GA

"Sussex Fran" wrote:

If a workbook contains, say 20 worksheets, is there a way of
protecting/unprotecting all the sheets at the same time to avoid going into
each one separately to protect?
Using Office Excel 2003.



All times are GMT +1. The time now is 03:35 PM.

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