Sub Combinaisons()
Dim t, tablo, rc&, resu1(), resu2(), resu3(), ub&, i&, j&, test As Byte, n1, n2, n3, dep1, dep2, dep3
t = Timer
tablo = [OFFSET(C4,,,COUNT(C:C))]
If IsArray(tablo) Then 'sécurité
rc = Rows.Count - 3
ReDim resu1(1 To rc, 1 To 2)
ReDim resu2(1 To rc, 1 To 2)
ReDim resu3(1 To rc, 1 To 2)
ub = UBound(tablo)
For i = 1 To ub - 1
test = tablo(i, 1) Mod 2 'parité 1 ou 0
For j = i + 1 To ub
Select Case test + (tablo(j, 1) Mod 2)
Case 0: n1 = n1 + 1: If n1 <= rc Then resu1(n1, 1) = tablo(i, 1): resu1(n1, 2) = tablo(j, 1)
Case 2: n2 = n2 + 1: If n2 <= rc Then resu2(n2, 1) = tablo(i, 1): resu2(n2, 2) = tablo(j, 1)
Case 1: n3 = n3 + 1: If n3 <= rc Then resu3(n3, 1) = tablo(IIf(test, j, i), 1): resu3(n3, 2) = tablo(IIf(test, i, j), 1)
End Select
Next j, i
End If
'---restitutions---
Application.ScreenUpdating = False
With ActiveSheet
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
.Range("E4:L" & .Rows.Count).ClearContents 'RAZ
If n1 Then If n1 <= rc Then .[E4].Resize(n1, 2) = resu1 Else dep1 = n1 - rc
If n2 Then If n2 <= rc Then .[H4].Resize(n2, 2) = resu2 Else dep2 = n2 - rc
If n3 Then If n3 <= rc Then .[K4].Resize(n3, 2) = resu3 Else dep3 = n3 - rc
With .UsedRange: End With 'actualise la barre de défilement verticale
End With
MsgBox "Durée des calculs " & Format(Timer - t, "0.00 \sec")
If dep1 Then MsgBox "Le tableau E4 dépasse les limites de la feuille de " & dep1 & " lignes !", 48
If dep2 Then MsgBox "Le tableau H4 dépasse les limites de la feuille de " & dep2 & " lignes !", 48
If dep3 Then MsgBox "Le tableau K4 dépasse les limites de la feuille de " & dep3 & " lignes !", 48
End Sub