Bonjour, je rencontre un problème je suis en train de developper une macro me permettant de mettre "X" tant que le cumul en colonne ne dépasse une valeur.
Le problème ici c'est que ma macro marche très bien pour les 3 premières colonnes mais à partir de la 4 ème colonne il y a une boucle infinie qui se crée.
Voici la macro en question :
Sub lisser()
'
Dim cumul As Integer
cumul = 0
i = 3
Col = 8
Do Until Cells(2, 8).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
While Cells(2, Col).Value + Cells(i, 7).Value < 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Wend
End If
End Sub
et je vous joins en PJ l'excel exemple
Le problème ici c'est que ma macro marche très bien pour les 3 premières colonnes mais à partir de la 4 ème colonne il y a une boucle infinie qui se crée.
Voici la macro en question :
Sub lisser()
'
Dim cumul As Integer
cumul = 0
i = 3
Col = 8
Do Until Cells(2, 8).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
Do Until Cells(2, Col).Value + Cells(i, 7).Value >= 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Loop
End If
Col = Col + 1
If Cells(2, 8).Value <> 0 Then
While Cells(2, Col).Value + Cells(i, 7).Value < 105
cumul = cumul + Cells(i, 7).Value
Worksheets("Feuil3").Cells(i, Col).Value = "X"
i = i + 1
Wend
End If
End Sub
et je vous joins en PJ l'excel exemple