Protection Members
Use the Worksheet objects Protection method to get a reference to the Protection object. The Protection object has the following members:
|
AllowDeletingColumns |
AllowDeletingRows |
|
AllowEditRanges |
AllowFiltering |
|
AllowFormattingCells |
AllowFormattingColumns |
|
AllowFormattingRows |
AllowInsertingColumns |
|
AllowInsertingHyperlinks |
AllowInsertingRows |
|
AllowSorting |
AllowUsingPivotTables |
The Protection object provides a set of read-only properties that describe the types of protection in effect on a worksheet. These settings correspond to the settings in the Protect Sheet dialog box and to the arguments used in the Worksheet object’s Protect method. For example, the following code displays a report on the Protection property settings in the Immediate window:
Set ws = ThisWorkbook.Sheets("Protection")
Set prot = ws.Protection
Debug.Print "Can delete:", "Columns?", "Rows?"
Debug.Print , prot.AllowDeletingColumns, prot.AllowDeletingRows
Debug.Print "Can:", "Filter?", "Sort?", "Use Pivot Tables?"
Debug.Print , prot.AllowFiltering, prot.AllowSorting, prot.AllowUsingPivotTables
Debug.Print "Can format:", "Cells?", "Columns?", "Rows?"
Debug.Print , prot.AllowFormattingCells, prot.AllowFormattingColumns, _
prot.AllowFormattingRows
Debug.Print "Can insert:", "Columns?", "Rows?", "Hyperlinks?"
Debug.Print , prot.AllowInsertingColumns, prot.AllowInsertingRows, _
prot.AllowInsertingHyperlinksYou also use the Protection object to get a reference to the AllowEditRanges ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access