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

Understanding Functions

The heart of any formula you put together in Excel is worksheet functions. This tip introduces you to worksheet functions and ...

Discover More

Ampersands in Headers and Footers

Add an ampersand to the text in a header or footer and you may be surprised that the ampersand disappears on your printout. ...

Discover More

Printing Web Discussions

If you are using the Web discussions feature built into some versions of Excel, you may want to print out a discussion at ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Pasting Into a Comment

Pasting the contents of a single cell into a comment is rather easy. Pasting the contents of a range of cells is a different ...

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

Printing Formatted Comments

When you print your worksheet, you may want Excel to include your comments as they appear on the screen. Here's how to make ...

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 4 + 2?

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.