how can i concatenate many cell in one cell

inspectoRQ

New Member
Joined
Jun 15, 2011
Messages
38
hi all!

example
a b c d
id name car
0141 john toyota
0186 chris mercedes
0141 john crysler
0141 john bmw
0112 marry range rover
0116 john(b) wolkvagen


how can i concatenate the all cars belongs one id in cell d?assume that there are thousands of cells like these
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
hi all!

example
a b c d
id name car
0141 john toyota
0186 chris mercedes
0141 john crysler
0141 john bmw
0112 marry range rover
0116 john(b) wolkvagen


how can i concatenate the all cars belongs one id in cell d?assume that there are thousands of cells like these
Having the results in a single cell requires that you add
the following function code in VBA to your workbook as a module.

In order to add the function to your workbook, run...

ALt+F11
Insert | Module
File | Close and Return to Microsoft Excel.
_________________________________________________________

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
________________________________________________________

Now equipped with ACONCAT...

Assuming that the sample you posted is in A1:C7, the headers included...

E2: 0141

F2, control+shift+enter, not just enter:

=SUBSTITUTE(aconcat(IF($A$2:$A$7=E2,", "&$C$2:$C$7,"")),", ","",1)
 
Upvote 0
hi again. i`m newbie at vba. i didnt work or i couldnt make it work. could you explain a little bit more
 
Upvote 0
hi again. i`m newbie at vba. it didnt work or i couldnt make it work. could you explain a little bit more
 
Upvote 0
yes i did. alt+f11 copy and paste there save as a workbook and closed.after i wrote the function that you show.if you have skype let me contact you pls
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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