I have around 25 worksheets in my workbook (Excel spreadsheet). Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time consuming
views:
2402answers:
3
+5
A:
I don't believe there's a way to do it without using VBA. If you are interested in a VBA solution, here is the code:
Dim ws as Worksheet
Dim pwd as String
pwd = "" ' Put your password here
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
Unprotecting is virtually the same:
Dim ws as Worksheet
Dim pwd as String
pwd = "" ' Put your password here
For Each ws In Worksheets
ws.Unprotect Password:=pwd
Next ws
Ben Hoffstein
2008-10-10 14:02:41
+2
A:
Don't think there's a button to do it, but it's simple enough code:
For Each protSheet In Worksheets protSheet.Protect Password := "boo" Next protSheet
Steven Robbins
2008-10-10 14:05:07