Protection Property

Protection Property

Office 2003

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    Required. An expression that returns a Worksheet object.


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


Applies to | Worksheet Object

© 2016 Microsoft