Inserting comment in unlocked cell in protected sheet

D

DevoGuy

I am un-protecting the worksheet, adding a new column for data. The cells in
the new column are unprotected and I would like to allow for the insertion of
comments after re-protecting the worksheet.

Code 1 (with blank for password) works but Code 2 (with password "PW Code")
causes error in line 5. What is correct syntax for Code 2 Line 5? Any help
would be appreciated. Thanks in advance.

‘Code 1 Leaving Password Blank

1 Sheets("Sheet1").Select
2 ActiveSheet.Unprotect
3 Worksheets("Sheet1").Columns("D:D").Select
4 Selection.Insert Shift:=xlToRight
5 ActiveSheet.Protect DrawingObjects:=False

‘Code 2 Using password “PW Codeâ€

1 Sheets("Sheet1").Select
2 ActiveSheet.Unprotect ("PW Code")
3 Worksheets("Sheet1").Columns("D:D").Select
4 Selection.Insert Shift:=xlToRight
5 ActiveSheet.Protect ("PW Code") DrawingObjects:=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top