UserAccess Object

Microsoft Excel Visual Basic

UserAccess Object

AllowEditRange UserAccessList
UserAccess

Represents the user access for a protected range.

Using the UserAccess object

Use the Add method or the Item property of the UserAccessList 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 AllowEdit property. The following example adds a range that can be edited on a protected worksheet and notifies the user the title of that range.

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