Add cell content in list of (threaded) comments

Geiss

New Member
Joined
Jan 29, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
'm starting to use VBA for work and I've found this VBA below, to create a list of my threaded comments on a new worksheet.

It creates a table with the number, cell, name, date, and text of the comment. And it works great, but I was hoping to find a way to include the value of the cell of the comment.
And actually it would be even better if it could be the value of the cell in the first column of the row where the comment is posted.

Hope someone can help me out with this.

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

Dim myCmt As CommentThreaded
Dim curwks As Worksheet
Dim newwks As Worksheet
Dim i 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", "Cell", "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
   End With
Next myCmt

With newwks
  .Columns(6).ColumnWidth = 50
  .Columns.AutoFit
  With .Cells
    .EntireRow.AutoFit
    .VerticalAlignment = xlTop
    .WrapText = True
  End With
End With

Application.ScreenUpdating = True

End Sub
 
Last edited by a moderator:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,110
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
     .Cells(i, 7).Value = curwks.Range("A" & myCmt.Parent.Row).Value
 

Forum statistics

Threads
1,144,628
Messages
5,725,376
Members
422,621
Latest member
dfrare

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
Top