VBA: Add or Remove Cell Comments from a Macro

August 14th, 2004 | Categories: VBA | Tags:
-->

Modifying a worksheet from code? Why not drop a comment in then to let the user know about what you’ve just done? The following code snippets show you how to add or delete a comment in a cell.

1. Put the following code somewhere in your macro to add a comment

Sheet1.Range("A1").AddComment ("Hello World")

2. To delete a comment use this code

Sheet1.Range("A1").Comment.Delete
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. Buddy
    December 31st, 2010 at 16:54
    Reply | Quote | #1

    a better way is with a range…

    ActiveSheet.Range(“A1:Z999″).ClearComments

    works with ’07 Excel

    • Carlyle
      February 15th, 2011 at 08:26
      Reply | Quote | #2

      Buddy… do you know of a way to make this conditional based on the contents of the comment? Such as a blank comment or specific text?

      Thank you