Forum Discussion

nickii95's avatar
nickii95
Copper Contributor
Mar 25, 2022
Solved

VBA Protect and Unprotect for a specific sheet

Dear Community,    This VBA allows me to protect and unprotect the workbook. However, I would prefer just a few sheets rather than the whole workbook. Sub ProtectWB_Protect_All_Sheets_Pswrd() ...
  • HansVogelaar's avatar
    Mar 25, 2022

    nickii95 

    Like this:

    Sub ProtectWB_Protect_All_Sheets_Pswrd()
        ActiveWorkbook.Unprotect "password"
        Worksheets("a").Protect Paswword:="eren", DrawingObjects:=True, Contents:=True, Scenarios:=True
        Worksheets("b").Protect Paswword:="eren", DrawingObjects:=True, Contents:=True, Scenarios:=True
        Worksheets("c").Protect Paswword:="yeagar", DrawingObjects:=True, Contents:=True, Scenarios:=True
        ActiveWorkbook.Protect "password"
    End Sub

Resources