AllowInsertingRows Property Example

This example locks all cells on the specified spreadsheet, and then it enables the filtering and sorting of rows and columns but disables the inserting, deleting, or sizing of rows and columns.

Spreadsheet1.Cells.Locked = True
Set pt = Spreadsheet1.ActiveSheet.Protection
pt.AllowDeletingColumns = False
pt.AllowDeletingRows = False
pt.AllowFiltering = True
pt.AllowInsertingColumns = False
pt.AllowInsertingRows = False
pt.AllowSizingAllColumns = False
pt.AllowSizingAllRows = False
pt.AllowSorting = True
pt.Enabled = True