Users Property

Microsoft Excel Visual Basic

Users Property

       

Returns a UserAccessList object for the protected range on a worksheet.

expression.Users

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

In this example, Microsoft Excel displays the name of the first user allowed access to the first protected range on the active worksheet. This example assumes that a range has been chosen to be protected and that a particular user has been given access to this range.

Sub DisplayUserName()

    Dim wksSheet As Worksheet

    Set wksSheet = Application.ActiveSheet

    ' Display name of user with access to protected range.
    MsgBox wksSheet.Protection.AllowEditRanges(1).Users(1).Name

End Sub