Grouping like combinations

leebauman

Board Regular
Joined
Jul 1, 2004
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hello, my data contains thousands of orders with a variety of item possibilities. I want to count the like item combinations.

In column A are my order numbers and column B are the items for each order

I want an output that shows the "like" item groups and references the associated order numbers (like in columns D & E below)

Much appreciated

1611120828246.png
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this:
VBA Code:
Sub a1159007a()
Dim i As Long
Dim va
Dim d As Object

va = Range("A2:B" & Cells(Rows.Count, "A").End(xlUp).Row)

Set d = CreateObject("scripting.dictionary")
d.CompareMode = vbTextCompare
For i = 1 To UBound(va, 1)
If d.Exists(va(i, 1)) Then
    d(va(i, 1)) = d(va(i, 1)) & ", " & va(i, 2)
Else
    d(va(i, 1)) = va(i, 2)
End If

Range("D2").Resize(d.Count, 2) = Application.Transpose(Array(d.Items, d.Keys))
Next


End Sub

Book1
ABCDE
1ORDERITEMITEM GROUPORDER
2CPaxtonPaxton, Derek, PatrickC
3CDerekZaiden, Zander, PaxtonN
4CPatrickDerek, PatrickU
5NZaidenZeinY
6NZander
7NPaxton
8UDerek
9UPatrick
10YZein
Sheet1
 
Upvote 0
Solution

Forum statistics

Threads
1,215,429
Messages
6,124,843
Members
449,193
Latest member
MikeVol

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