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.

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

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