Share via


AllowSorting Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Returns True if the sorting option is allowed on a protected worksheet. Read-only Boolean.

expression.AllowSorting

expression   Required. An expression that returns a Protection object.

Remarks

Sorting can only be performed on unlocked or unprotected cells in a protected worksheet.

The AllowSorting property can be set by using the Protect method arguments.

Example

This example allows the user to sort unlocked or unprotected cells on the protected worksheet and notifies the user.

  Sub ProtectionOptions()

    ActiveSheet.Unprotect

    ' Unlock cells A1 through B5.
    Range("A1:B5").Locked = False

    ' Allow sorting to be performed on the protected worksheet.
    If ActiveSheet.Protection.AllowSorting = False Then
        ActiveSheet.Protect AllowSorting:=True
    End If

    MsgBox "For cells A1 through B5, sorting can be performed on the protected worksheet."

End Sub