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:

[TABLE="width: 330"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Seattle Supply Works[/TD]
[TD]123[/TD]
[/TR]
[TR]
[TD]Seattle Supply Works[/TD]
[TD]Main Street[/TD]
[/TR]
[TR]
[TD]Seattle Supply Works[/TD]
[TD]Kent, WA 98032[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Levittontown DC[/TD]
[TD]cc Property Mgmt[/TD]
[/TR]
[TR]
[TD]Levittontown DC[/TD]
[TD]456[/TD]
[/TR]
[TR]
[TD]Levittontown DC[/TD]
[TD]East Main Street[/TD]
[/TR]
[TR]
[TD]Levittontown DC[/TD]
[TD]Suite 300[/TD]
[/TR]
[TR]
[TD]Levittontown DC[/TD]
[TD]East Brunswick, NJ 08816[/TD]
[/TR]
</tbody>[/TABLE]


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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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