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
| Sub Combinaison()
Dim DerCol As Long, DerLig As Long, Nb_Comb As Long
Dim c As Long, l As Long, Lig As Long, m As Long
Dim q As Long, Qte As Long
Application.ScreenUpdating = False
'**************************************************************************************
'Détection du nombre de fonctions à analyser
Col = 21
Do While Cells(1, Col) = 0
Col = Col - 1
Loop
DerCol = Col 'Dernière colonne contenant au moins 1 valeur parmi les 5 option
DerLig = 7 'Dernière ligne
Nb_Comb = 1
For i = Col To 2 Step -2
Nb_Comb = Nb_Comb * Cells(1, i)
Next i
'Marquage
m = 1 'multiplicateur
For c = DerCol To 3 Step -2
Lig = 11
If c = DerCol Then m = 1 Else m = m * Cells(1, c + 2)
Qte = Cells(1, c)
Do
For q = 1 To Qte
If c = DerCol Then
Range(Cells(Lig, c - 1), Cells(Lig, c)) = q
Lig = Lig + 1
Else
Range(Cells(Lig, c - 1), Cells(Lig + m - 1, c)) = q
Lig = Lig + m
End If
Next q
Loop While Lig <= Nb_Comb + 10
Next c
'Remplacement du marquage par les valeurs
DerLig = Range("B10").End(xlDown).Row
For l = 11 To DerLig
For c = 2 To DerCol Step 2
Select Case Cells(l, c)
Case 1
Range(Cells(l, c), Cells(l, c + 1)).Value = Range(Cells(3, c), Cells(3, c + 1)).Value
Case 2
Range(Cells(l, c), Cells(l, c + 1)).Value = Range(Cells(4, c), Cells(4, c + 1)).Value
Case 3
Range(Cells(l, c), Cells(l, c + 1)).Value = Range(Cells(5, c), Cells(5, c + 1)).Value
Case 4
Range(Cells(l, c), Cells(l, c + 1)).Value = Range(Cells(6, c), Cells(6, c + 1)).Value
Case 5
Range(Cells(l, c), Cells(l, c + 1)).Value = Range(Cells(7, c), Cells(7, c + 1)).Value
End Select
Next c
Next l
End Sub |
Partager