Sub Protect_All_Formula_cells()
Application.ScreenUpdating = False
For i = 1 To Sheets.Count
With Sheets(i)
.Unprotect Password:="abcd"
With .Cells
.Locked = False
.FormulaHidden = False
End With
Cells.SpecialCells(xlCellTypeFormulas, 23).Select 'error line: you cannot use this command on protected sheet
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
.Protect Password:="abcd", DrawingObjects:=True, Contents:=True, Scenarios:=True, _
AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowInsertingHyperlinks:=True, AllowFiltering:=True
End With
Next i
Application.ScreenUpdating = True
End Sub
I have tried unprotecting the sheet with the code but still getting the error.
Solution??
Bookmarks