VBA to concatenate cells if same value exists in another column

VBAAccountant

New Member
Joined
Jun 12, 2018
Messages
15
I'm not even sure where to start with this one.
ckfinder.html
I have the following scenerio:

AB
Seattle Supply Works123
Seattle Supply WorksMain Street
Seattle Supply WorksKent, WA 98032
Levittontown DCcc Property Mgmt
Levittontown DC456
Levittontown DCEast Main Street
Levittontown DCSuite 300
Levittontown DCEast Brunswick, NJ 08816

<tbody>
</tbody>


I would like a VBA code to look at any duplicate cells in column A and concatenate the items in column B for those duplicate cells in column C:

C
Seattle Supply Works 123 Main Street, Kent, WA 98032
Levittontown DC cc Property Mgmt, 456 East Main Street, Suite 300, East Brunswick, NJ 08816

I would like the concatenated data in C to be listed on each duplicate line.
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this

Code:
Sub Concatenate()
    j = 2
    ant = Cells(2, "A").Value
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row + 1
        If Cells(i, "A").Value <> ant Then
            cad = ant & " " & cad
            Cells(j, "C").Value = cad
            cad = ""
            j = j + 1
        End If
        cad = cad & " " & Cells(i, "B").Value
        ant = Cells(i, "A").Value
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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