Hi,
I’ve got this Vb code By “JINDON” and it gives result in 3 columns,what line of the code need to be changed so it give me result in 4 or more columns?
Sub test()
Dim a, b(), i As Long, ii As Long, iii As Long, n As Long, e, flg As Boolean
a = Range("a1").CurrentRegion.Value
Redim b(1 To Application.Combin(UBound(a, 1), 3), 1 To 3)
With CreateObject("System.Collections.ArrayList")
For i = 2 To UBound(a, 1) / 3
For ii = i + 1 To UBound(a, 1) - 2
For iii = ii + 1 To UBound(a, 1)
.Clear
For Each e In Split(Join$(Array(a(i, 1), a(ii, 1), a(iii, 1))))
If Not .contains(e) Then
.Add e
Else
flg = False
Exit For
End If
Next
If flg Then
n = n + 1
b(n, 1) = a(i, 1)
b(n, 2) = a(ii, 1)
b(n, 3) = a(iii, 1)
End If
flg = True
Next
Next
Next
End With
Range("g2").Resize(n, 3).Value = b
End Sub
Thank you and much appreciate any help in advance.
Regards
Sem.
Bookmarks