1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub test3()
Dim Plage As Range, C As Range
With Sheets("Feuil1")
Set Plage = .Range(.[A1], .Cells(.Rows.Count, 1).End(xlUp))
For Each C In Plage
If C.Offset(, 1) = "" Then
C.Offset(, 1) = C.Value
C = ""
End If
Next C
.[C:C].Insert
Plage.Offset(, 2).Formula = "=ROW()"
Plage.Offset(, 2).Value = Plage.Offset(, 2).Value
Plage.Resize(, 3).Sort .[A1], xlDescending, Header:=xlNo
Plage.Resize(, 3).Sort .[B1], xlAscending, Header:=xlNo
For Each C In Plage
If C.Value <> "" And C.Offset(, 1).Value = C.Offset(1, 1).Value Then
C.Offset(1) = C
End If
Next C
Plage.Resize(, 3).Sort .[C1], xlAscending, .[C1], Header:=xlNo
.[C:C].Delete
End With
End Sub |
Partager