Concatenate by group excluding current row

maelstromm

New Member
Joined
Mar 17, 2015
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I am trying to good way to concatenate items that are grouped by a column but excludes the item in the current row. The only reference I could find to a similar task was here. But this is a fairly manual method and I wonder if there is an easier way to do this with a macro especially with a data set that is 8000 rows and has 300 groups. Here is a sample of what I am trying to do:

[TABLE="width: 380"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD]Item[/TD]
[TD]Group[/TD]
[TD]Related[/TD]
[/TR]
[TR]
[TD]Item 1[/TD]
[TD]Group 1[/TD]
[TD]Item 2[/TD]
[/TR]
[TR]
[TD]Item 2[/TD]
[TD]Group 1[/TD]
[TD]Item 1[/TD]
[/TR]
[TR]
[TD]Item 3[/TD]
[TD]Group 2[/TD]
[TD]Item 4, Item 5[/TD]
[/TR]
[TR]
[TD]Item 4[/TD]
[TD]Group 2[/TD]
[TD]Item 3, Item 5[/TD]
[/TR]
[TR]
[TD]Item 5[/TD]
[TD]Group 2[/TD]
[TD]Item 3. Item 4[/TD]
[/TR]
[TR]
[TD]Item 6[/TD]
[TD]Group 3[/TD]
[TD]Item 7, Item 8, Item 9, Item 10[/TD]
[/TR]
[TR]
[TD]Item 7[/TD]
[TD]Group 3[/TD]
[TD]Item 6, Item 8, Item 9, Item 10[/TD]
[/TR]
[TR]
[TD]Item 8[/TD]
[TD]Group 3[/TD]
[TD]Item 6, Item 7, Item 9, Item 10[/TD]
[/TR]
[TR]
[TD]Item 9[/TD]
[TD]Group 3[/TD]
[TD]Item 6, Item 7, Item 8, Item 10[/TD]
[/TR]
[TR]
[TD]Item 10[/TD]
[TD]Group 3[/TD]
[TD]Item 6, Item 7, Item 8, Item 9[/TD]
[/TR]
</tbody>[/TABLE]


Thank you for your help!!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
This UDF should do the trick.
Formula in C2: =Related(A2,B2,$B$2:$B$11)
Copy down as far as required

Code:
Function Related(Item As String, Group As String, Groups As Range)
Dim c As Range
For Each c In Groups
    If c = Group And c.Offset(, -1) <> Item Then Related = Related & c.Offset(, -1) & ", "
Next c
Related = Left(Related, Len(Related) - 2)
End Function
 
Upvote 0
That is correct. Thank you for the quick response. I will give it a shot and let you know!
 
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