Excell Add Comment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I check if a Cell has a comment field in VBA before I try and ADD a
comment?

e.g.

if Cells(A,1).Comment = True
Cells(A,1).Comment.Delete
Else
Cells(A,1).AddComment
Cells(A,1).Comment.Text("My Text")
 
Hi Bob,

Try something like:

'=============>>
Public Sub Tester()
Dim rng As Range

Set rng = ActiveCell '<<==== CHANGE

If Not rng.Comment Is Nothing Then
'Existing comment, do nothing
Else
rng.Comment.Add
'Your code
End If

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top