Name

range.AddComment( )

Synopsis

Adds a comment to the specified range. The following code adds a comment to cells with batting averages .300 and over:

Dim r As Range
Dim rwIndex As Integer
 
For rwIndex = 1 To 3
    Set r = Worksheets("WombatBattingAverages").Cells(rwIndex, 2)
    With r
         If .Value >= 0.3 Then
              .AddComment "All Star!"
         End If
    End With
Next rwIndex

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.