• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

readonly excel for specific users and full access to other users


New Member
i have an excel wrkbk with 2 sheets,
sheet1 has full data
sheet 2 contains list of users to admin & readonly
Column A Column B
Name Access
Sam Paul Readonly
Tim AK Readonly
Akika YS Admin
John Smith Admin

how can i amend the code to read the sheet2 list of users and make the workbook readonly to e.g sam Paul & Tim AK

ive tried below.. but need to add multiple users want to do it dynamic without change in vba code but read cell values only

If Application.UserName <> 'Akika YS' Then
ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
End If


Active Member
Hi akika,
I assume you mean something like this:
Sub a()
    Dim numusers As Double
    Dim permoption As String
    numusers = Sheets("Sheet2").Range("A1").End(xlDown).Row
    permoption = Application.WorksheetFunction.VLookup(Application.UserName, Sheets("Sheet2").Range("A2:B" & numusers), 2, False)
    If permoption = "Readonly" Then ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
End Sub
If this message was helpful, please click 'Like!' on the bottom right.

Stevie ^.^