checks the UserName; if it is not Admin, this code protects each sheet from user changes : Workbook Protect « Excel « VBA / Excel / Access / Word






checks the UserName; if it is not Admin, this code protects each sheet from user changes

 
Private Sub Workbook_Open()
    Dim sht As Worksheet
    If Application.UserName <> "Admin" Then
        For Each sht In Worksheets
            sht.Protect UserInterfaceOnly:=True
        Next sht
    End If
End Sub

 








Related examples in the same category

1.Protect workbook
2.Show the workbook protection
3.Unprotect Workbook