excel protect cells with formulas

The solution for “excel protect cells with formulas” can be found here. The following code will assist you in solving the problem.

‘ 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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts