Retrieving Multiple Comments

tamrob23

Board Regular
Joined
Jun 20, 2006
Messages
203
Good Afternoon,

I wrote a VBA in Excel (below) so I can retrieve comments but I quickly realized that people are using multiple cells in multiple columns to make comments. Is there anyway I can create something that will automatically find the comments and put them in an empty cell? If I continue to use what I created below, I'm going from 8 columns to 16 (because I'm creating a column to retrieve the comments). Please help!



Function Comment(incell) As String
On Error Resume Next
Comment = incell.Comment.Text
End Function
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi Tamara,

Use this code. Modify the myrange according to your needs.


Code:
Function Comment(ByVal incell As Range) As String
On Error GoTo A:
Comment = incell.Comment.Text
Exit Function
A:
Comment = "Doesn't Exist"
End Function

Sub All_Comments()
Dim myrange As Range, myarray() As String
Set myrange = Range("A1:Z100")
For Each cell In myrange
If Not Comment(cell) = "Doesn't Exist" Then
    k = k + 1
    ReDim Preserve myarray(1 To k) As String
    myarray(k) = Comment(cell)
End If
Next

For i = 1 To UBound(myarray)
Range("AA1").Offset(i - 1) = myarray(i)
Next i
End Sub
 
Upvote 0
Basically above code will scan all the cells in the range("A1:Z100") and record the comments found in a single column AA starting from row 1.

So modify range("A1:Z100") and Range("AA1") according to your situation
 
Upvote 0
I just ran it and this is perfect! With the way you arranged the range, I can manipulate each workbook as to where I would like for the comments to go. Thank you so much Mahammad, have a great day!
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,859
Members
449,194
Latest member
HellScout

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