Protect workbook : Workbook Protect « Excel « VBA / Excel / Access / Word






Protect workbook

 
Sub ProtectWorkbook()
    Dim wb As Workbook
    Set wb = ThisWorkbook
    wb.Protect "Excel2003", True, True
    'wb.Unprotect
End Sub

 








Related examples in the same category

1.Show the workbook protection
2.Unprotect Workbook
3.checks the UserName; if it is not Admin, this code protects each sheet from user changes