Hi there,
I have a worksheet that I have enabled grouping on in order to allow expandable fields for entering text. I want the worksheet to be protected, and I currently have 4 worksheets with grouping that need to be protected.
I tried entering this code, but I am getting run-time errors and errors when I try to expand the grouping. The passwords are the same and I have edited the sheet references as applicable.
Any suggestions are greatly appreciated. I am using Excel 2003.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
Select Case UCase(ws. Name)
Case "SHEET1", "SHEET3", "SHEET5"
With ws
.Protect Password:="Secret", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Case Else
End Select
Next ws
End Sub
I also tried this code:
Private Sub Workbook_Open()
With Sheet1
.Protect Password:="Secret", UserInterfaceOnly:=True
.EnableOutlining = True
End With
End Sub
and this one:
Private Sub Workbook_Open()
With Worksheets("Sheet1")
.EnableOutlining = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
End With
End Sub
I have a worksheet that I have enabled grouping on in order to allow expandable fields for entering text. I want the worksheet to be protected, and I currently have 4 worksheets with grouping that need to be protected.
I tried entering this code, but I am getting run-time errors and errors when I try to expand the grouping. The passwords are the same and I have edited the sheet references as applicable.
Any suggestions are greatly appreciated. I am using Excel 2003.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
Select Case UCase(ws. Name)
Case "SHEET1", "SHEET3", "SHEET5"
With ws
.Protect Password:="Secret", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Case Else
End Select
Next ws
End Sub
I also tried this code:
Private Sub Workbook_Open()
With Sheet1
.Protect Password:="Secret", UserInterfaceOnly:=True
.EnableOutlining = True
End With
End Sub
and this one:
Private Sub Workbook_Open()
With Worksheets("Sheet1")
.EnableOutlining = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
End With
End Sub