Class UserAccess (Excel VBA)

The class UserAccess represents the user access for a protected range.


To use a UserAccess class variable it first needs to be instantiated, for example

Dim strName As String: strName = 
Dim ual As UserAccessList: Set ual = 
Dim usrac As UserAccess
Set usrac = ual.Add(Name:=strName, AllowEdit:=True)

The following procedures can be used to set variables of type UserAccess: UserAccessList.Item, UserAccessList.Add and AllowEditRange.Users

For Each

Here is an example of processing the UserAccess items in a collection.

Dim aer As AllowEditRange: Set aer = 
Dim usracUser As UserAccess
For Each usracUser In aer.Users
Next usracUser


Returns or sets a Boolean value that indicates if the user is allowed access to the specified range on a protected worksheet.


Deletes the object.


Returns or sets a String value that represents the name of the object.


Adds a user access list.

Syntax : expression.Add (Name, AllowEdit)


The following arguments are required:

Name (String) - The name of the user access list.

AllowEdit (Boolean) - True allows users on the access list to edit the editable ranges on a protected worksheet.


Returns a Long value that represents the number of objects in the collection.


Removes all users who have access to a protected range on a worksheet.

Sub UseDeleteAll() 
 Dim wksSheet As Worksheet 
 Set wksSheet = Application.ActiveSheet 
 ' Remove all users with access to the first protected range. 
End Sub


Returns a single UserAccess object from the collection.

For more information about returning a single member of a collection, see Returning an object from a collection.

Syntax : expression.Item (Index)

Index: The name or index number of the object.