LOCK and PROTECT Cells Containing FORMULAS in an Excel Worksheet

Excel Junction Guide 8 years ago

Description

You may not want other users to change, edit or delete your formulas. At times, even you yourself may accidentally mess them up. The probability of such errors increases a lot when you share a file with your colleagues, bosses or clients. Several corporates have lost millions due to spreadsheet disasters.

This video shows you a fast and easy way of protecting all your formulas in the worksheet at one go. There's a VBA code that’ll help us achieve this and it would not take more than a few seconds. Even those who are not acquainted with VBA can easily get this done by simply following the steps on how to use this code:

CODE

Sub ProtectFormulas()
‘ExcelJunction.com
Dim strPassword As String
With ActiveSheet
.Unprotect
.Cells.Locked = False
.Cells.SpecialCells(xlCellTypeFormulas).Locked = True
.Protect AllowDeletingRows:=True
strPassword = InputBox("Please enter the password (optional)", "Formula Protection powered by ExcelJunction.com”)
ActiveSheet.Protect Password:=strPassword
End With
End Sub