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
| Sub verification()
Application.ScreenUpdating = False
ligne = Range("e65536").End(xlUp).Row
Dim X As Integer
Cells.Font.ColorIndex = 1
start:
X = 0
Cells.Font.ColorIndex = 1
For i = 2 To ligne
If Cells(i, 5).Value = "2" Then
X = X + 1
End If
If Cells(i - 1, 5).Value = "2" And Cells(i, 5).Value <> "2" Then
GoTo copie
End If
If Cells(i, 5).Value = "" Then
GoTo fin
End If
Next i
copie:
For f = 2 To ligne
If Cells(f, 5).Value = "2" And f > X Then
Cells(f, 5).Value = Cells(f - X, 5).Value
Cells(f, 5).Font.ColorIndex = 4
Cells(f, 9).Value = Cells(f - X, 9).Value
Cells(f, 9).Font.ColorIndex = 4
Cells(f, 10).Value = Cells(f - X, 10).Value
Cells(f, 10).Font.ColorIndex = 4
End If
If Cells(f + 1, 5).Value <> "2" And Cells(f, 5).Font.ColorIndex <> 1 Then
GoTo start
End If
If Cells(f, 5).Value = "" Then
GoTo fin
End If
Next f
fin:
End Sub |
Partager