I want to merge cells using vlookup

Hansulet

Board Regular
Joined
Jan 24, 2013
Messages
173
Office Version
  1. 2021
Platform
  1. Windows
How Can I merge cells using vlookup?

I have to merge cells from TEXT Column for each ID

ID NAME TEXT
1 AAA hfjkjvk
1 AAA djhjfdhf
1 AAA dfklkdfj
2 BBB dffdffd
2 BBB dsffdf
3 CCC ddsvds
4 DDD vdsdvv
3 CCC vsdvdv
5 EEE fvfgfgf
1 AAA fgvfvvfv
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thank you for your interest.

This is initial data base:

A B C
ID NAME TEXT

1 AAA hfjkjvk
1 AAA djhjfdhf
1 AAA dfklkdfj
2 BBB dffdffd
2 BBB dsffdf
3 CCC ddsvds
4 DDD vdsdvv
3 CCC vsdvdv
5 EEE fvfgfgf
1 AAA fgvfvvfv


Now, I need to merge in column D the data from column C.
So, the result is as follows:

A B D
ID NAME RESULT

1 AAA hfjkjvk djhjfdhf dfklkdfj fgvfvvfv
2 BBB dffdffd dsffdf
3 CCC ddsvds vsdvdv
4 DDD vdsdvv
5 EEE fvfgfgf
 
Upvote 0
In column A is ID
In column B is NAME
In column C is TEXT
In column D is RESULT

In other words, I need to concatenate in a single cell in column D all data from column C for the same name.
 
Upvote 0
If you're interested in a VBA solution, try this
Code:
Sub ConcatDuplicates()

   Dim Cl As Range
   Dim Strng As String
   Dim Itm As Variant
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then
            .Add Cl.Value, Array(Cl.Offset(, 1).Value, Cl)
         Else
            Strng = .Item(Cl.Value)(0) & "," & Cl.Offset(, 1).Value
            .Item(Cl.Value) = Array(Strng, .Item(Cl.Value)(1))
            Debug.Print .Item(Cl.Value)(0)
         End If
      Next Cl
      For Each Itm In .items
         Itm(1).Offset(, 2).Value = Itm(0)
      Next Itm
   End With
         
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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