• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to check if the cell has comment

ThrottleWorks

Excel Ninja
Hi,

I am trying to assign comment to a cell. I want to check if comment is already present then leave it else create comment for the cell.

I tried various solutions from Google but somehow not able to do it. Can anyone please help me in this.

I am trying below mentioned code to generate comment.
Code:
PosSht.Cells(TempLr - 1, 13).AddComment
PosSht.Cells(TempLr - 1, 13).Comment.Visible = True
PosSht.Cells(TempLr - 1, 13).Comment.Text Text:="Chandoo is awesome !"
PosSht.Cells(TempLr - 1, 13).Comment.Visible = False
 
try this...


Code:
Sub t()
Dim i As Integer, cmt As Comment

For i = 1 To 5
    With Cells(i, 1)
        Set cmt = .Comment
            If cmt Is Nothing Then
                .AddComment "Chandoo is awesome !"
                .Comment.Visible = True
            End If
    End With
Next

Set cmt = Nothing
End Sub
 
Back
Top