Question : Copy "Protect Sheet" setttings to all tabs in a workbook

I have an excel 2007 workbook where I have protected one sheet with certain settings:
Allow all users of this sheet to:
Select locked cells
Select unlocked cells

How do I copy these protection selections to all the other sheets in the workbook (they have different selections) without doing it one by one?
Thanks in advance,

Answer : Copy "Protect Sheet" setttings to all tabs in a workbook

Try the code below in the ThisWorkbook code pane. It runs automatically when the workbook opens and protects every worksheet with a password. The user is allowed to select locked and unlocked cells.

To access this code pane, ALT + F11 to open the VBA Editor. In the Project Explorer on the left, doubleclick ThisWorkbook. Paste the code there. It won't work at all if installed anywhere else.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
Private Sub Workbook_Open()
Dim ws As Worksheet
Dim MyPassword As String
MyPassword = "abc"
For Each ws In ActiveWorkbook.Worksheets
    ws.Protect Password:=MyPassword, UserInterfaceOnly:=True, Contents:=True
Next
End Sub
Random Solutions  
 
programming4us programming4us