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
|
Private Sub Optimisation_Click()
Dim mot As String, i, j, var$
Application.ScreenUpdating = False
'Ici je recupère le nombre de produits différents
longueur = Range("b12")
'La valeur maxi de mon indicateur est initialisé à 0
Max = 0
zeros = "0"
For a = 1 To longueur
zeros = "0" & zeros
Next
mot = "0"
Do While Len(mot) <= longueur
If InStr(mot, "0") <> 0 Then
mot = Left(mot, InStr(mot, "0") - 1) & "1" & Right(mot, Len(mot) - InStr(mot, "0"))
var = Right(zeros & mot, longueur)
For j = 1 To longueur
Cells(j + 12, 19) = Mid(var, j, 1)
If Range("d9") > Max Then
Max = Range("d9")
For a = 1 To longueur
Cells(a, 200) = Cells(12 + a, 19)
Next
End If
Next
Else
mot = "1" & String(Len(mot), "0")
var = Right(zeros & mot, longueur)
For j = 1 To longueur
Cells(j + 12, 19) = Mid(var, j, 1)
If Range("d9") > Max Then
For b = 1 To longueur
Cells(b, 200) = Cells(12 + b, 19)
Next
End If
Next
End If
Loop
For c = 1 To longueur
Cells(12 + c, 19) = Cells(c, 200)
Next
Application.ScreenUpdating = True
End Sub |
Partager