Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I retrieve the text of a cell comment

Tags:

excel

vba

I find lots of examples for creating but none for retrieving the text of a cell comment. Am I missing something obvious?

like image 415
gssi Avatar asked Feb 13 '23 10:02

gssi


2 Answers

Range.Comment.Text seems to work without any problem here...

(e. g. if not ActiveCell.Comment is nothing then debug.print ActiveCell.Comment.Text)

like image 136
KekuSemau Avatar answered Feb 19 '23 09:02

KekuSemau


Try going for:

Dim comtext as string

If ActiveCell.Comment Is Nothing Then
        comtext = ""
        Else
        comtext = ActiveCell.Comment.Text
        End If

As for me, if you want to paste comment text as other cell value you might need to use:

Selection.ClearFormats

since sometimes comment text which you pasted or set cell value might be invisible at first.

PS. This is my first post ever on this side, so I've just started learning the ropes.

like image 40
Rafał Tulisz Avatar answered Feb 19 '23 07:02

Rafał Tulisz