Name

worksheet.Protection

Synopsis

Returns a Protection object that represents the protection attributes of the worksheet.

The following code displays a message if you can’t delete rows in a worksheet:

If ActiveSheet.Protection.AllowDeletingRows = False Then
    MsgBox "Sorry, you can't delete this row."
End If

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.