Sub Test()
Dim varComment As String
Dim c As Comment
With Range("A1")
On Error Resume Next
Set c = .Comment
On Error GoTo 0
If c Is Nothing Then
MsgBox "No comment", vbExclamation
Else
varComment = c.Text
MsgBox varComment, vbInformation
End If
End With
End Sub
So if i want to adapt this for another purpose, how would it work... where is the destination cell in this case?
I want to display the comments of a a cell based on a criteria, but I'm not sure how to revert to the cell comments.
I can't even display A1 comments in another cell on a test sheet....
Function getComment(rng As Range) As String
Application.Volatile
Dim str As String
If rng.Comment Is Nothing Then
getComment = ""
Else
str = rng.Comment.Text
str = Right(str, Len(str) - InStr(1, str, ":") - 1)
End If
getComment = str
End Function