- Detect if any cell in a range contains any threaded comments
Function hasComment(rng As Range) As Boolean
On Error Resume Next
hasComment = False
For Each cell In rng
If Not cell.CommentThreaded Is Nothing Then
hasComment = True
Exit For
End If
Next cell
End Function - Get the full threaded comment in a cell
Function GetCellComments(cell As Range) As String
Dim threadedComment As CommentThreaded
Dim n As Integer, i As Integer
If hasComment(cell) = True Then
GetCellComments = cell.CommentThreaded.Author.Name & ": " & _ cell.CommentThreaded.Text
n = cell.CommentThreaded.Replies.Count
If n >= 1 Then
For i = 1 To n
GetCellComments = GetCellComments & " | " & _ cell.CommentThreaded.Replies(i).Author.Name & _ ": " & cell.CommentThreaded.Replies(i).Text
Next
End If
End If
End Function - Get the all threaded comments within a range
Function GetRangeComments(rng As Range) As String
GetRangeComments = ""
If hasComment(rng) = True Then
For Each cell In rng
If GetCellComments(cell.Offset(0, 0)) <> "" Then
GetRangeComments = GetRangeComments & "[" & cell.Address & "]" & _
GetCellComments(cell.Offset(0, 0))
End If
Next cell
End If
End Function
0 Comments