ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting comment in unlocked cell in protected sheet (https://www.excelbanter.com/excel-programming/384743-inserting-comment-unlocked-cell-protected-sheet.html)

DevoGuy

Inserting comment in unlocked cell in protected sheet
 
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



All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com