Home > Forum Home > Developing and Auditing Analytical Models > Concatenate Comments for Rows Above Each Record ID > Concatenate Comments VBA code Share

Concatenate Comments VBA code

Excel Help for Concatenate Comments Vba Code in Developing and Auditing Analytical Models


Forum TopicLogin

Concatenate Comments Vba Code

Rate this:
(3/5 from 1 vote)
HappyAssuming that you have the Record ID in column A, the Comment in column B and the Results in column C, the following VBA macro will work. I have tested it.

VBA Code:
Sub Concatenate_Comments()
Application.ScreenUpdating = False
Dim strResult As String
Dim strComment As Variant
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
For Each strComment In Selection
    'If not ID
    If Trim(strComment.Offset(0, -1).Text) = "" Then
        'Build onto Result
        strResult = strResult & " " & strComment
        'Put nothing in the Result
        strComment.Offset(0, 1).Formula = ""
    'Else there is an ID
    Else
        'Build onto Result
        strResult = strResult & " " & strComment
        'Put the Result
        strComment.Offset(0, 1).Formula = strResult
        'Release the Result for the next one
        strResult = ""
    End If
Next
Application.ScreenUpdating = True
End Sub

Enjoy!
 Excel Business Forums Administrator
 Posted by on
 
View Full Post

Find relevant Excel templates and add-ins for Concatenate Comments VBA code in the