Sub BuildUserList()
Dim ws As Worksheet, ual As UserAccessList, aer As AllowEditRange, _
usr As UserAccess
Set ws = ThisWorkbook.Sheets("Protection")
ws.Unprotect "Excel2003"
Set aer = ws.Protection.AllowEditRanges("Edit Range")
Set ual = aer.Users
Set usr = ual.Add("Administrators", True)
Set usr = ual.Add("Users", True)
Set usr = ual.Add("Guests", False)
For i = 1 To ual.Count
Set usr = ual(i)
Debug.Print usr.Name
Next
ws.Protect "Excel2003"
End Sub
|