Adding Comments to Protected Worksheets

by Allen Wyatt
(last updated December 7, 2017)

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

Printing Styles in a Macro

There may be times when you want your macro to print out a list of styles in the document. If so, then you can do it with ...

Discover More

Word Counts for a Group of Documents

Getting a word count for a single document is easy. Getting an aggregate word count for a large number of documents can ...

Discover More

Finding Cells that Use Conditional Formatting

Conditional Formatting is a great boon to effectively displaying the information in your worksheets. If you want to ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Formatting Text in Comment Boxes

Want to make your worksheet comments appear a certain way? It's easy to do using techniques you already are familiar with.

Discover More

Comments Don't Appear when Cell is Pointed To

One way that you can view comments in a worksheet is to have them appear when you hover the mouse pointer over a cell. If ...

Discover More

Counting Comments in a Worksheet

Need to know how many comments are in a worksheet? You can figure out the count manually, or you can apply the handy ...

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 8 - 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.