by Allen Wyatt
(last updated April 26, 2019)
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:
Figure 1. The Protect Sheet dialog box.
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, 2013, 2016, 2019, and Excel in Office 365.
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!
Need to find that misplaced comment in your worksheet? It's easy to do using the Find and Replace capabilities of Excel.Discover More
Comments can be very helpful in a worksheet. After they are added, you may want to change what they contain. Here's how ...Discover More
Want your comment boxes to appear someplace other than the right side of a cell? You may be out of luck, and here's why.Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.