
Option Explicit Sub Commentiamo() Dim oCmt As Comment For Each oCmt In ActiveSheet.Comments Debug.Print oCmt.Parent.Address Next oCmt End Sub |
Option Explicit
Sub Commentiamo()
Dim myRange As Range, cell As Range, v
Set myRange = [F1:G10]
For Each cell In myRange
If Not cell.Comment Is Nothing Then
v = Array(cell.Comment.Text, cell.Address)
Debug.Print "Commento "; v(0) & "Indirizzo "; v(1)
End If
NextEnd Sub |
Function Commento(r As Range) As String
Application.Volatile True
Commento = "<" & r.Address & ": nessun commento inserito>"
If HasComment(r) Then
If Trim(r.Comment.Text) = "" Then
Commento = "<" & r.Address & ": commento vuoto>"
Else
Commento = "<" & r.Address & ": " & r.Comment.Text
End If
End If
End Function
Private Function HasComment(r As Range) As Boolean
HasComment = Not (r.Comment Is Nothing)
End Function |
