Try the attched
Sub test()
Dim a, i As Long, ii As Long, e, s, dic As Object, myMax As Long, t As Long
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
a = Sheets("sheet1").Cells(1).CurrentRegion.Value
With CreateObject("VBScript.RegExp")
.Global = True
.Pattern = "[\W_\d]"
For i = 2 To UBound(a, 1)
If Not dic.exists(a(i, 1)) Then
Set dic(a(i, 1)) = CreateObject("Scripting.Dictionary")
dic(a(i, 1)).CompareMode = 1
End If
For ii = 3 To UBound(a, 2)
For Each e In Split(Application.Trim(.Replace(a(i, ii), " ")))
dic(a(i, 1))(e) = dic(a(i, 1))(e) + 1
Next
Next
myMax = Application.Max(myMax, dic(a(i, 1)).Count)
Next
ReDim a(1 To myMax + 1, 1 To dic.Count * 3): t = -2
For Each e In dic
i = 1: t = t + 3
a(i, t) = e: a(i, t + 1) = "Count"
For Each s In dic(e)
i = i + 1: a(i, t) = CStr(s): a(i, t + 1) = dic(e)(s)
Next
Next
End With
Application.ScreenUpdating = False
With Sheets("sheet3").Cells(1).Resize(UBound(a, 1), UBound(a, 2))
.NumberFormat = "@": .Value = a
For i = 1 To UBound(a, 2) Step 3
.Columns(i + 1).NumberFormat = ""
.Columns(i).Resize(, 2).Sort .Cells(1, i), 1, , , , , , True
Next
.Columns.AutoFit
End With
Application.ScreenUpdating = True
End Sub
Bookmarks