Home » Questions » Computers [ Ask a new question ]

Excel: Move cell contents to comment

Excel: Move cell contents to comment

I'm using Excel 2007.

Asked by: Guest | Views: 167
Total answers/comments: 2
Guest [Entry]

"The following VBA code will move the text values of the selected cells into the comments. It will only work if there arent any existing commnets

Sub Test()
For i = 1 To Selection.Rows.Count
For j = 1 To Selection.Columns.Count
Selection.Cells(i, j).AddComment (Selection.Cells(i, j).Text)
Next
Next
End Sub"
Guest [Entry]

"I've expanded on the given answer, so that no comments are added for empty cells and to move rather than copy the text:
Sub Text2Comment()
For i = 1 To Selection.Rows.Count
For j = 1 To Selection.Columns.Count
If Selection.Cells(i, j) <> """" Then
Selection.Cells(i, j).AddComment (Selection.Cells(i, j).Text)
Selection.Cells(i, j) = """"
End If
Next
Next
End Sub"