Finance

Charts

Statistics

Macros

Search

Sorting Data on a Protected Sheet with Excel VBA

Data on a protected sheet can be sorted if they are within a range where the Locked property is set to False, and if the AllowSorting parameter of the Protect method is set to True.

The read-only property AllowSorting of the Protection object returns the value of this parameter. For example, the code allows sorting the range A1:A5 on a protected sheet, if it has not been enabled previously.

Sorting on a Protected Sheet

Sub DemoAllowSorting()
    ActiveSheet.Unprotect
    Range("A1:A5").Locked = False
    If ActiveSheet.Protection.AllowSorting Then
        ActiveSheet.Protect AllowSorting:=True
    End If
End Sub
0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx