A list of all threaded comments from one workbook with a hyperlink to the cell

LuluExcel

New Member
Joined
Feb 28, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I found this code online to extract threaded comments and replies. I would like to make these modifications:
1. extract comments from all worksheets
2. In column 2 "Reference", show a hyperlink to the cell with the sheet name as the text.
Thank you in advance!!!

VBA Code:
Sub ListCommentsRepliesThreaded()
Application.ScreenUpdating = False

Dim myCmt As CommentThreaded
Dim myRp As CommentThreaded
Dim curwks As Worksheet
Dim newwks As Worksheet
Dim myList As ListObject
Dim i As Long
Dim iR As Long
Dim iRCol As Long
Dim ListCols As Long
Dim cmtCount As Long

Set curwks = ActiveSheet
cmtCount = curwks.CommentsThreaded.Count

If cmtCount = 0 Then
   MsgBox "No threaded comments found"
   Exit Sub
End If

Set newwks = Worksheets.Add

 newwks.Range("A1:F1").Value = _
     Array("Number", "Reference", "Author", _
      "Date", "Replies", "Text")

i = 1
For Each myCmt In curwks.CommentsThreaded
   With newwks
     i = i + 1
     On Error Resume Next
     .Cells(i, 1).Value = i - 1
     .Cells(i, 2).Value = myCmt.Parent.Address
     .Cells(i, 3).Value = myCmt.Author.Name
     .Cells(i, 4).Value = myCmt.Date
     .Cells(i, 5).Value = myCmt.Replies.Count
     .Cells(i, 6).Value = myCmt.Text
   If myCmt.Replies.Count > 1 Then
    iR = 1
    iRCol = 7
    For iR = 1 To myCmt.Replies.Count
      .Cells(1, iRCol).Value = "Reply " & iR
      .Cells(i, iRCol).Value _
        = myCmt.Replies(iR).Author.Name _
          & vbCrLf _
          & myCmt.Replies(iR).Date _
          & vbCrLf _
          & myCmt.Replies(iR).Text
      iRCol = iRCol + 1
    Next iR
   End If
   End With
Next myCmt

With newwks
.ListObjects.Add(xlSrcRange, _
  .Cells(1, 1) _
    .CurrentRegion, , xlYes) _
    .Name = ""
End With

Set myList = newwks.ListObjects(1)
myList.TableStyle = "TableStyleLight8"
ListCols = myList.DataBodyRange _
  .Columns.Count

With myList.DataBodyRange
  .Cells.VerticalAlignment = xlTop
  .Columns.EntireColumn.ColumnWidth = 30
  .Cells.WrapText = True
  .Columns.EntireColumn.AutoFit
  .Rows.EntireRow.AutoFit
End With

Application.ScreenUpdating = True

End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top