0

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!

z_11122
  • 153
  • 8
  • 3
    `but this did not work` What do you mean by this? Any error message? `Sheets("Hastus Workbook").Unprotect "password"` is the correct way to do it. Also you will benefit by reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Siddharth Rout Jul 30 '21 at 15:19
  • @SiddharthRout I figured it out on my own. Thanks for the answer anyways! – z_11122 Aug 08 '21 at 01:17

0 Answers0