You are not answering to my last question.
Sub test()
Dim a, i As Long, ii As Long, n As Long, w()
Dim txt As String, temp As String, refCol As Long
refCol = Application.InputBox("Select column", Type:=8).Column
ReDim w(1 To 2)
With Sheets(1).Range("b2").CurrentRegion
a = .Value
refCol = refCol - .Column + 1
End With
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(a, 1)
txt = a(i, 1) & ";;" & a(i, 2)
temp = ""
If Not .exists(txt) Then
n = n + 1
For ii = 1 To UBound(a, 2)
a(n, ii) = a(i, ii)
temp = temp & ";;" & a(i, ii)
Next
Set w(1) = _
CreateObject("Scripting.Dictionary")
w(1).CompareMode = 1
w(1)(temp) = Empty
w(2) = n
.Item(txt) = w
Else
For ii = 1 To UBound(a, 2)
temp = temp & ";;" & a(i, ii)
Next
If Not .Item(txt)(1).exists(temp) Then
a(.Item(txt)(2), refCol) = _
a(.Item(txt)(2), refCol) & ", " & a(i, refCol)
.Item(txt)(1)(temp) = Empty
End If
End If
Next
End With
With Sheets(2).Range("b2")
.CurrentRegion.ClearContents
.Resize(n, UBound(a, 2)).Value = a
End With
End Sub
Bookmarks