Grouping with protected sheets (multiple sheets)

Joined
Oct 28, 2009
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top