Simply trying to enable both the formatting options as well as the expand / collapse option for a locked and protected workbook which has a few tabs in it. It seems to work when I run it .. but when I close and open the work book only the formatting works and the expand/collapse does not work.. Any help is greatly appreciated.. as I am not good at Excel coding :P
Private Sub Format_Workbook()
Dim wks As Worksheet
Dim wkbk As Workbook
Set wkbk = ActiveWorkbook
For Each wks In wkbk.Worksheets
wks.Unprotect Password:="exceltemplate"
wks.Cells.Locked = False
Select Case (wks.Name)
Case "Sheet1", "Sheet2", "Sheet3", "Sheet4"
With wks
.Protect Password:="exceltemplate", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Case Else
End Select
On Error Resume Next
wks.UsedRange.SpecialCells(xlCellTypeFormulas).Locked = True
On Error GoTo 0
wks.Protect Password:="exceltemplate", AllowFormattingCells:=True, _
AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True
Next wks
End Sub
Bookmarks