1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Sub combinaison()
[A7.I65536].ClearContents
Dim n22 As Integer, x22 As Integer, n42 As Integer, x42 As Integer, n23 As Integer, x23 As Integer, n43 As Integer, x43 As Integer, Z As Integer, X As Integer, a As Integer, Aa As Integer, Ab As Integer
Dim T22 As Single, T42 As Single, T23 As Single, T43 As Single, MAX As Integer, MIN As Integer, Y As Integer, W As Integer
Dim Ligne As Long
Z = [A1]
X = [F1]
Aa = [A3]
Ab = [F3]
T22 = [J1]
T42 = [L1]
T23 = [J3]
T43 = [L3]
MAX = [N1]
MIN = [N3]
Ligne = 7
For n22 = 0 To Z 'on boucle 4 fois (0, 1, 2, 3) alors qu'on a que 3 tournée (Z =3) | For n22 = 1 To Z serait mieux non?
For x22 = 0 To X
For n42 = 0 To Z
For x42 = 0 To X
For n23 = 0 To Z
For x23 = 0 To X
For n43 = 0 To Z
For x43 = 0 To X
a = n22 * x22 * 8 + n42 * x42 * 8 + n23 * x23 * 10 + n43 * x43 * 10
' 1 2
If n22 = 0 Xor x22 = 0 Then a = 0 'attention avec Xor si n22 et x22 sont à 0, ta condition n'est pas validé - alors qu'avec Or à la place de Xor oui
If n42 = 0 Xor x42 = 0 Then a = 0
If n23 = 0 Xor x23 = 0 Then a = 0
If n43 = 0 Xor x43 = 0 Then a = 0
If Aa < a And a <= Ab Then
Cells(Ligne, 1).Value = n22
Cells(Ligne, 2).Value = x22
Cells(Ligne, 3).Value = n42
Cells(Ligne, 4).Value = x42
Cells(Ligne, 5).Value = n23
Cells(Ligne, 6).Value = x23
Cells(Ligne, 7).Value = n43
Cells(Ligne, 8).Value = x43
Cells(Ligne, 9).Value = a
For Y = x22 To x42
For W = x23 To x43
If MIN * Y <= n22 * T22 * x22 + n42 * x42 * T42 And n22 * T22 * x22 + n42 * x42 * T42 <= MAX * Y Xor MIN * W <= n23 * T23 * x23 + n43 * T43 * x43 And n23 * x23 * T23 + n43 * x43 * T43 <= MAX * W Then
Ligne = Ligne + 1
End If
Next
Next
End If 'ajouté
Next
Next
Next
Next
Next
Next
Next
Next
End Sub |