A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I found that adding comments to cells using vba on a protected spreadsheet was a bit tricky (as the UserInterfaceOnly property of the protect method didn't seem to work with the .AddComment Method), perhaps one of the MVPs knows a way around this, in the meantime, here's my attempt:
Private Sub CommandButton1_Click()
'Unprotect the sheet using your password
Sheet1.Unprotect Password:="enteryourpasswordhere"
'Clear the comments on the target cell
' - this prevents errors when adding comments to a cell that already contains comments.
Range("A1").ClearComments
'Add a comment to the cell
Range("A1").AddComment ("This is my comment")
'Or as an alternative example you can use:
'Range("A1").AddComment (Range("A2").Value)
'Reprotect the sheet using your password
Sheet1.Protect Password:="enteryourpasswordhere"
End Sub
The big downside to this code is that it contains your sheet protection password, so you'd have to lock the VBA Project for viewing.
Essentially this code adds a comment to cell A1, the second option adds the value of cell A2 as a comment to cell A1.