How to list certain details about all comments in a worksheet?

leonlai

Board Regular
Joined
Mar 22, 2019
Messages
77
Hi,

I have an Excel Sheet1 with data in it and several comments scattered here and there.

I think each comment has an identification number automatically assigned to it when it is created?
Maybe ID? or Item? Not sure!

I want a VBA macro to list all the comments to another sheet (say Sheet2) together with the following information:
(a) The identification of the comment.
(b) Its Text.

The reason: I will use them later.

The following thread comes close to my requirement, but it does not display the identification of the comment.
Can you, please help?

Thanks
Leon

---
https://www.mrexcel.com/forum/excel...ents.html?highlight=NEED+TO+SHOW+ALL+COMMENTS

Code:
Sub b()

Dim cmt As Comment
Dim c As Range
Dim aWs As Worksheet

Set aWs = ActiveSheet

Sheets.Add

For Each c In aWs.UsedRange
    Set cmt = c.Comment
        If Not cmt Is Nothing Then
            Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = c.Address
            Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) = cmt.Text
        End If
Next c

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi leonlai,

Welcome to the MrExcel Forum.

Does this do what you want...

Code:
Sub b()


    Dim cmt As Comment
    Dim aWs As Worksheet
    Dim nam As String
    Dim i As Long
    
    nam = ActiveSheet.Name
    Set aWs = Worksheets(nam)
    i = 1
    Sheets.Add
    For Each cmt In aWs.Comments
        Set cmt = aWs.Comments.Item(i)
            If Not cmt Is Nothing Then
                With cmt.Shape
                    Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = .Name
                    Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) = .DrawingObject.Text
                    i = i + 1
                End With
            End If
    Next


End Sub
 
Last edited:
Upvote 0
You're welcome. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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