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
| Sub cherche_negatif()
Range("I14:I143").ClearContents
For lig = 14 To 50
If Cells(lig, 29).Value = "négatif" Then
Cells(lig - 1, 9).Value = Cells(lig, 3).Value + Cells(lig - 1, 3).Value
End If
If Cells(lig - 1, 9).Value < 0 Then
Cells(lig - 2, 9).Value = Cells(lig - 1, 9).Value + Cells(lig - 2, 3).Value
End If
If Cells(lig - 2, 9).Value < 0 Then
Cells(lig - 3, 9).Value = Cells(lig - 2, 9).Value + Cells(lig - 3, 3).Value
End If
If Cells(lig - 3, 9).Value < 0 Then
Cells(lig - 4, 9).Value = Cells(lig - 3, 9).Value + Cells(lig - 4, 3).Value
End If
If Cells(lig - 4, 9).Value < 0 Then
Cells(lig - 5, 9).Value = Cells(lig - 4, 9).Value + Cells(lig - 5, 3).Value
End If
If Cells(lig - 5, 9).Value < 0 Then
Cells(lig - 6, 9).Value = Cells(lig - 5, 9).Value + Cells(lig - 6, 3).Value
End If
If Cells(lig - 6, 9).Value < 0 Then
Cells(lig - 7, 9).Value = Cells(lig - 6, 9).Value + Cells(lig - 7, 3).Value
End If
If Cells(lig - 7, 9).Value < 0 Then
Cells(lig - 8, 9).Value = Cells(lig - 7, 9).Value + Cells(lig - 8, 3).Value
End If
If Cells(lig - 8, 9).Value < 0 Then
Cells(lig - 9, 9).Value = Cells(lig - 8, 9).Value + Cells(lig - 9, 3).Value
End If
If Cells(lig - 9, 9).Value < 0 Then
Cells(lig - 10, 9).Value = Cells(lig - 9, 9).Value + Cells(lig - 10, 3).Value
End If
If Cells(lig - 10, 9).Value < 0 Then
Cells(lig - 11, 9).Value = Cells(lig - 10, 9).Value + Cells(lig - 11, 3).Value
End If
Next lig
For x = 14 To 50
If Cells(x, 9).Value < 0 Then
Cells(x, 9).Value = 0
End If
Next x
End Sub |
Partager