Share via


Protection Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Returns a Protection object that contains the protection properties for the specified worksheet. The protection properties are ignored if the Enabled property is set to False.

expression.Protection

expression   Required. An expression that returns a Worksheet object.

Example

This example locks the cells in column B and enables protection for the sheet.

  Sub ProtectColumnB()

   ' Unlock all of the cells in the active sheet.
   Spreadsheet1.ActiveSheet.Cells.Locked = False

   ' Lock the cells in column B.
   Spreadsheet1.Columns(2).Locked = True

   ' Protect the locked cells.
   Spreadsheet1.ActiveSheet.Protection.Enabled = True

End Sub