Example

Use the method or the property of the collection to return a UserAccess object.

Once a UserAccess object is returned, you can determine if access is allowed for a particular range in an worksheet, using the property. The following example adds a range that can be edited on a protected worksheet and notifies the user the title of that range.

Visual Basic for Applications
Sub UseAllowEditRanges() Dim wksSheet As Worksheet Set wksSheet = Application.ActiveSheet ' Add a range that can be edited on the protected worksheet. wksSheet.Protection.AllowEditRanges.Add "Test", Range("A1") ' Notify the user the title of the range that can be edited. MsgBox wksSheet.Protection.AllowEditRanges(1).Title End Sub

See also: