A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
If you want to apply the code to all worksheets:
Sub Auto_Open()
Dim wsh As Worksheet
For Each wsh In Worksheets
With wsh
.Protect Password:="hi", UserInterfaceOnly:=True
.EnableOutlining = True
'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
End With
Next wsh
End Sub
and if you want to apply it to specific sheets only:
Sub Auto_Open()
Dim wsh As Worksheet
' Specify the names of the sheets in the array
For Each wsh In Worksheets(Array("Sheet1", "Sheet2", "Sheet3"))
With wsh
.Protect Password:="hi", UserInterfaceOnly:=True
.EnableOutlining = True
'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
End With
Next wsh
End Sub