Worksheet.Protect (Excel)

Protects a worksheet so that it cannot be modified.

Protect (Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)


ActiveSheet.Protect

Arguments

Optional arguments

The following arguments are optional

Password (String) - A string that specifies a case-sensitive password for the worksheet or workbook. If this argument is omitted, you can unprotect the worksheet or workbook without using a password. Otherwise, you must specify the password to unprotect the worksheet or workbook. If you forget the password, you cannot unprotect the worksheet or workbook. Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better. It is critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

DrawingObjects (Boolean) - True to protect shapes. The default value is True.

Contents (Boolean) - True to protect contents. For a chart, this protects the entire chart. For a worksheet, this protects the locked cells. The default value is True.

Scenarios (Scenarios) - True to protect scenarios. This argument is valid only for worksheets. The default value is True.

UserInterfaceOnly (Boolean) - True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.

AllowFormattingCells (Boolean) - True allows the user to format any cell on a protected worksheet. The default value is False.

AllowFormattingColumns (Boolean) - True allows the user to format any column on a protected worksheet. The default value is False.

AllowFormattingRows (Boolean) - True allows the user to format any row on a protected worksheet. The default value is False.

AllowInsertingColumns (Boolean) - True allows the user to insert columns on the protected worksheet. The default value is False.

AllowInsertingRows (Boolean) - True allows the user to insert rows on the protected worksheet. The default value is False.

AllowInsertingHyperlinks (Boolean) - True allows the user to insert hyperlinks on the protected worksheet. The default value is False.

AllowDeletingColumns (Boolean) - True allows the user to delete columns on the protected worksheet, where every cell in the column to be deleted is unlocked. The default value is False.

AllowDeletingRows (Boolean) - True allows the user to delete rows on the protected worksheet, where every cell in the row to be deleted is unlocked. The default value is False.

AllowSorting (Boolean) - True allows the user to sort on the protected worksheet. Every cell in the sort range must be unlocked or unprotected. The default value is False.

AllowFiltering (Boolean) - True allows the user to set filters on the protected worksheet. Users can change filter criteria but can not enable or disable an auto filter. Users can set filters on an existing auto filter. The default value is False.

AllowUsingPivotTables (Boolean) - True allows the user to use PivotTable reports on the protected worksheet. The default value is False.