Bonsoir, voici mon problème : j'ai une VBA qui me donne tout les combinaisons de 4 chiffres dans un intervalles de 1 à 40 mais on retrouve plusieurs fois les même combinaisons. Exemple
Col A Col B Col C Col D
1 2 8 36
... . .. ... ...
36 2 8 1
et voici ma VBA :
Dim r&(1 To 300000, 1 To 4), col&, i1&, i2&, i3&, i4&, k&
col = 1
For i1 = 1 To 40
For i2 = 1 To 40
If i1 <> i2 Then
For i3 = 1 To 40
If i3 <> i1 And i3 <> i2 Then
For i4 = 1 To 40
If i4 <> i1 And i4 <> i2 And i4 <> i3 Then
k = k + 1
r(k, 1) = i1
r(k, 2) = i2
r(k, 3) = i3
r(k, 4) = i4
If k = 300000 Then
Cells(1, col).Resize(k, 4) = r
col = col + 5
Erase r
k = 0
End If
End If
Next i4
End If
Next i3
End If
Next i2
Next i1
If k > 0 Then
Cells(1, col).Resize(k, 4) = r
End If
Est-ce que quelqu’un aurait bien une solution pour enlever les combinaisons identiques svp ?
merci et bonne soirée à tous !