This vba code is to protect formulas and worksheets
I want to unprotect worksheet with vba code
Thanks you
Thomas
I want to unprotect worksheet with vba code
VBA Code:
Sub protectFormulasAndEnableProtection()
Dim sht As Worksheet
On Error Resume Next
For Each sht In Sheets
sht.Activate
sht.Unprotect
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
If Err.Number = 1004 Then
'No special cells found (no formulas in this case). Clear the error and take no action
Err.Clear
Else
Selection.Locked = True
Selection.FormulaHidden = False
End If
sht.Protect AllowFormattingColumns:=True, AllowFormattingRows:=True
Next sht
End Sub
Thanks you
Thomas