View Single Post
  #1   Report Post  
stuck
 
Posts: n/a
Default Using Collapse/Expand with Protected worksheets

Hello -- someone has posted this great code that works well to allow
this, but you need to list each individual worksheet. The problem is,
i want to give my users the option of changing the worksheet tab title,
and in fact this title is referenced repeatedly throughout the
workbook.

isn't there a way to apply this macro to "all worksheets" regardless of
the name?

the original code is below. Thanks very much!:

Private Sub Workbook_Open()


Dim mySheetNames As Variant
Dim iCtr As Long


'change to match your workbook
mySheetNames = Array("sheet1", "sheet2", "sheet3")


For iCtr = LBound(mySheetNames) To UBound(mySheetNames)
With Worksheets(mySheetNames(iCtr))
.Select
.EnableOutlining = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
End With
Next iCtr
End Sub