Adding Comments to Protected Worksheets

by Allen Wyatt
(last updated February 1, 2014)

5

Doug notes that Excel allows you to add comments to cells, but only if the worksheet is unprotected. He wonders if there is a way to allow the addition of comments in protected worksheets.

There are a few ways you can tackle this problem. The first is to simply modify how you protect your worksheet. Starting with an unprotected worksheet, follow these steps:

  1. Display the Home tab of the ribbon.
  2. In the Cells group, click Format | Protect Sheet. (You could also click the same tool on the Review tab of the ribbon.) Excel displays the Protect Sheet dialog box. (See Figure 1.)
  3. Figure 1. The Protect Sheet dialog box.

  4. Enter a password to be used in protecting the worksheet.
  5. Scroll down in the list of permissions and select the Edit Objects check box. (Comments are considered objects in Excel.)
  6. Set any other permissions desired.
  7. Click OK to dismiss the dialog box. If you provided a password in step 3 you are prompted to reenter it, which you should do.

Any worksheet user can now add comments to cells. Note that this allows them to add comments to any cells in the worksheet, not just to those cells that you've formatted as unlocked. In addition, users can also modify (add, change, or delete) any other objects in the worksheet, such as drawings and charts.

If you want a more granular approach to dealing with comments in protected worksheets, then you'll need to resort to using a macro. The concept is to have the macro prompt the user for the comment text, unlock the worksheet, insert the comment, and then relock the worksheet.

Public Sub InsertComment()
    Dim sPassword As String
    Dim MyComment As String

    sPassword = "123"

    Set commentCell = ActiveCell
    MyComment = InputBox("Enter your comments", "Comments")

    ActiveSheet.Unprotect Password:=sPassword
    Range(commentCell.Address).AddComment
    Range(commentCell.Address).Comment.Text Text:=MyComment
    ActiveSheet.Protect Password:=sPassword
End Sub

Change the value assigned to the sPassword variable; this is required to unlock and relock the worksheet. Since you are storing the password in the macro, you'll also want to make sure that you take steps to protect the macro (put a password on the VBA module) so others cannot see the password. The macro can be assigned to a shortcut key or added to the Quick Access Toolbar.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12928) applies to Microsoft Excel 2007, 2010, and 2013.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Deleting Styles

As documents evolve, so do your needs for various styles. You may create new ones and, invariably, old ones need to be ...

Discover More

Deleting MRU Entries

By default Word dutifully keeps track of the different files you've worked on in the past. If you want to delete an entry ...

Discover More

Printing Documents in a Folder

If you want to print a group of documents at the same time there are a couple of ways you can accomplish the task. Here are ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Adjusting Comment Printouts

Need to print out comments, but in a way that you control what is included in the printout? Here's a way you can extract the ...

Discover More

Pasting a Comment into Your Worksheet

Excel allows you to not only put information into cells, but into comments attached to those cells. Here's how to copy the ...

Discover More

Changing Comment Color for a Single User

The default color used to format comments is determined by Windows, not Excel. You can adjust the formatting of individual ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one more than 9?

2014-10-13 10:23:59

Aline

1. I have a file with (password) protected sheets.
2. The data entry is restricted to a few cells
3. During the calculation I can run various macros (e.g. show and hide columns and rows, create new sheets with the same layout and cell protection etc)

I did as you described under point(s) 1. till 4. and now I have the problem that as soon as I run other macros in my file they seem to "overrule" this setting and I can no longer insert comments.

What I want/need is a macro (allows comments) that runs automatically when I open the workbook and which is not affected by other macros...


2014-06-06 19:16:11

Scott

That macro works to enter a new comment but what would the macro be to edit an existing comment? Thanks for the help.


2014-02-04 13:47:36

Don

My rationale for whether to allow people to select or not select cells has to do with whether there is sensitive information on the worksheet that should not be copied to some other document. Examples are financials during blackout period and some personnel data.

If there is no sensitive data then I let them select, copy, and paste elsewhere.

Excel already provides a general message that the data is not editable, so that is covered to some extent.

I've never had the need to intercept that message in order to replace it with something more context sensitive, nor do I see the opportunity in the Event lists for worksheets and workbooks presented by the VBE.


2014-02-03 08:03:15

Bryan

Andrew: why not? I'm kind of OCD about where my cursor is, and I like to scroll around using the arrow keys, which is jarring if you have protected cells. I can see an argument that users might get confused and wouldn't be able to figure out why they can't edit the cells, but I think this can be sorted through clarity of formatting and labels.


2014-02-03 04:23:53

Andrew

I never allow people to select locked cells in a protected workbook. Why do they need to select cells you do not want them to edit?
A couple of other useful options to tick is to allow sort and autofilter.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.