Protects a worksheet from modification. This method is equivalent in functionality to using the properties of the Protection object to protect your worksheet.
expression.Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTableReports)
expression Required. An expression that returns a Worksheet object.
Password Optional Variant. This argument is not supported.
DrawingObjects Optional Variant. This argument is not supported.
Contents Optional Variant. True to protect contents of the locked cells on the worksheet. The default value is True.
Scenarios Optional Variant. This argument is not supported.
UserInterfaceOnly Optional Variant. This argument is not supported.
AllowFormattingCells Optional Variant. This argument is not supported.
AllowFormattingColumns Optional Variant. True to allow the resizing of columns. The default value is False. Equivalent to the AllowSizingAllColumns property of the Protection object.
AllowFormattingRows Optional Variant. True to allow the resizing of rows. The default value is False. Equivalent to the AllowSizingAllRows property of the Protection object.
AllowInsertingColumns Optional Variant. True if worksheet columns can be inserted. The default value is False. Equivalent to the AllowInsertingColumns property of the Protection object.
AllowInsertingRows Optional Variant. True if worksheet rows can be inserted. The default value is False. Equivalent to the AllowInsertingRows property of the Protection object.
AllowInsertingHyperlinks Optional Variant. This argument is not supported.
AllowDeletingColumns Optional Variant. True if worksheet columns can be deleted. The default value is False. Equivalent to the AllowDeletingColumns property of the Protection object.
AllowDeletingRows Optional Variant. True if worksheet rows can be deleted. The default value is False. Equivalent to the AllowDeletingRows property of the Protection object.
AllowSorting Optional Variant. True if the specified worksheet can be sorted. The default value is False. Equivalent to the AllowSorting property of the Protection object.
AllowFiltering Optional Variant. True if the specified worksheet can be filtered. The default value is False. Equivalent to the EnableAutoFilter property of the Protection object.
AllowUsingPivotTableReports Optional Variant. This argument is not supported.
Protect method as it applies to the Workbook object.
Protects a workbook so that it cannot be modified.
expression.Protect(Password, Structure, Windows)
expression Required. An expression that returns a Workbook object.
Password Optional Variant. This argument is not supported.
Structure Optional Variant. True to protect the structure of the workbook. Protecting the structure of the workbook prevents sheets from being moved, inserted, deleted, hidden, unhidden and renamed. The default value is False.
Windows Optional Variant. This argument is not supported.
Remarks
Setting an unsupported argument to True will result in an run-time error.
Example
As it applies to the Worksheet object.
This example protects the contents of the locked cells on Sheet1 in Spreadsheet1 while allowing the user to insert and delete columns and rows.
Spreadsheet1.Worksheets("Sheet1").Protect , , True, , , , , , True, True, , True, True