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
|
Sub test()
Dim i As Long, j As Long, x As String
Dim CurLig As Long
Dim CurX As String
Application.ScreenUpdating = False
With Sheets(1)
CurLig = 1 '<-1ère ligne du tableau (hors éventuelle ligne d'entête)
CurX = .Cells(CurLig, 1) & .Cells(CurLig, 2) & .Cells(CurLig, 3)
i = CurLig + 1
While .Cells(i, 1).Value <> vbNullString
x = .Cells(i, 1) & .Cells(i, 2) & .Cells(i, 3)
If x = CurX Then
If .Cells(i, 4).Value < .Cells(CurLig, 4).Value Then
.Rows(i).Delete
Else
.Rows(CurLig).Delete
CurLig = i - 1
CurX = .Cells(CurLig, 1) & .Cells(CurLig, 2) & .Cells(CurLig, 3)
End If
Else
CurLig = i
CurX = .Cells(CurLig, 1) & .Cells(CurLig, 2) & .Cells(CurLig, 3)
i = i + 1
End If
Wend
End With
Application.ScreenUpdating = True
End Sub |
Partager