Unprotecting a worksheet using vba

I have a macro that already exists. Since creating that macro, I decided that some of the worksheets should be protected before proceeding with the macro.

 Range("A1:G3177").Select
    Selection.Copy
    Sheets("Hastus Workbook").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
 Sheets("Chart").Select

I protected the “Hastus Workbook” sheet by right clicking on the sheet name in excel. I would like to add a line to the code above that will unprotect this worksheet as part of my already-existing macro.

I tried inserting Sheets("Hastus Workbook").Unprotect "password" above the Sheets("Hastus Workbook").Select line, but this did not work. How can I make unprotect this sheet?

Thanks for the help!

Leave a Comment