I have below code to protect each sheet in a workbook. However when I run this, it only protects the first one. The for loop doesn't work for some reason. Anyone knows why?
Code:
Sub Macro1()
'
' Macro1 Macro
'
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowUsingPivotTables:=True, Password:="123"
ActiveSheet.EnableSelection = xlUnlockedCells
Next sh
End Sub
Last edited by a moderator: