Comment Macro

Viking1221

New Member
Joined
May 25, 2017
Messages
32
Hello,

I have a workbook with multiple tabs (40+). Each tab is set up the exact same way, there is just a tab for each location and shows their P&L. The first tab is a consolidated tab (same format as all others). Each tab shows a monthly trend and variance to goals. I add comments to each tab as I work through it highlighting the reasoning for the variances by row. I would like to have a macro that would search all the tabs (2-40) that would aggregate all my comments into the consolidated tab in the same cell it was added in the supporting tabs. For example, if I added a comment on tab 3 called "location 4" and tab 7 called "location 8" in cell C25 I would like the macro to search all the tabs and consolidate the comments into the "total' tab. The comment would read Location 4 - "XXXX" Location 8 - "YYY"

Is that even possible?

Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi,

I think this should work:
VBA Code:
Sub test()
  Dim totalRange As Range, varComment As String, tempComment As String, c As Comment
  Set totalRange = Worksheets("Total").UsedRange
 
  For Each ws In Worksheets
    If ws.Name <> "Total" Then
      For Each Rng In totalRange
        With ws.Range(Rng.Address)
        On Error Resume Next
        Set c = .Comment
        On Error GoTo 0
        If Not c Is Nothing Then
          varComment = c.Text
          If Not Rng.Comment Is Nothing Then
            tempComment = Rng.Comment.Text
            Rng.Comment.Delete
          End If
          Rng.AddComment tempComment & ws.Name & " - """ & varComment & """ "
        End If
        End With
      Next
    End If
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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