```
Sub aTestV2()
Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long
Dim lLin As Long, lResult(1 To 6) As Long
Dim rData As Range, rExclusion As Range
Set rData = Range("A2:N2")
Set rExclusion = Range("A5:B13")
lLin = 4
For i = 1 To 9
For j = i + 1 To 10
For k = j + 1 To 11
For l = k + 1 To 12
For m = l + 1 To 13
For n = m + 1 To 14
lResult(1) = Application.Index(rData, i)
lResult(2) = Application.Index(rData, j)
lResult(3) = Application.Index(rData, k)
lResult(4) = Application.Index(rData, l)
lResult(5) = Application.Index(rData, m)
lResult(6) = Application.Index(rData, n)
If CheckExclusion(lResult, rExclusion) = False Then
lLin = lLin + 1
Range("D" & lLin).Resize(1, 6) = lResult
End If
Next n
Next m
Next l
Next k
Next j
Next i
End Sub
Function CheckExclusion(lRes() As Long, rExclusion As Range) As Boolean
Dim rCell As Range
For Each rCell In rExclusion
If Not IsError(Application.Match(rCell.Value, lRes, 0)) Then
If Not IsError(Application.Match(rCell.Offset(, 1).Value, lRes, 0)) Then
CheckExclusion = True
Exit For
End If
End If
Next rCell
End Function[
[/QUOTE]
Sanjayaranj,
If you need to generate all the possibilities, this makes the code much more complex - I don't know how to calculate how many different sets would be possible (???)
I'm afraid I don't know how to do this.
M.
[/QUOTE]
Thank you Marcelo.
```