Add cell comments from one cell to another that already has commante in it

andyba

New Member
Joined
Sep 13, 2011
Messages
2
I have to combine the cell contents (values and cell comments) from one cell, to another cell (on the same row) that already contains a value and a comment. I can use paste special to add the values together (I don't need to retain the individual values) but I need to show both sets of comments in the resulting cell.

Eg Cell C2 has a value of 25.00 and a cell comment of CPA 1/5/11.
Cell D2 has a value of 75.00 and a cell comment of CPA 25/5/11.

Cell C2 should now show a value of 100.00 and a cell comment of CPA 1/5/11 CPA 25/5/11
This has to be carried out on several thousand rows of data.

Any help would be greatly appreciated.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this (untested) on a copy of your worksheet. Assumes your data start at C2 and Column D counterparts to C cells are what you want to add to the C cells.
Code:
Sub JoinValuesAndComments()
Dim cR As Range, dR As Range
Dim lrw As Long
lrw = Range("C" & Rows.Count).End(xlUp).Row
Set cR = ActiveSheet.Range("c2", "C" & lrw)
Set dR = cR.Offset(0, 1)
For i = 1 To cR.Rows.Count
    cR.Cells(i, 1).Value = cR.Cells(i, 1).Value + dR.Cells(i, 1).Value
    On Error Resume Next
    cR.Cells(i, 1).Comment.Text dR.Cells(i, 1).Comment.Text, Len(cR.Cells(i, 1).Comment.Text) + 1, False
    If Err.Number <> 0 Then
        cR.Cells(i, 1).AddComment dR.Cells(i, 1).Comment.Text
        On Error GoTo 0
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,217
Messages
6,123,675
Members
449,116
Latest member
HypnoFant

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