Answers for "how to protect a cell in excel"

VBA
0

excel protect cells with formulas

' Protects cells containing formulas, with password
' pPwd: password to protect / unprotect
Sub ProtectFormulas(ByRef pRange As Range, ByVal pPwd As String)
    ActiveSheet.Unprotect pPwd
    For Each r In pRange
        r.Locked = IIf(r.HasFormula, True, False)
    Next r
    ActiveSheet.Protect pPwd
End Sub

Sub TestIt()
    ProtectFormulas Range("A1:B4"), "MyPassWord"
End Sub
Posted by: Guest on January-17-2021

Code answers related to "how to protect a cell in excel"

Code answers related to "VBA"

Browse Popular Code Answers by Language