Re florianmonot,
Oui patrick, par précaution on pourrait restituer le résultat sur une autre feuille.
Ici restitution en Feuil2, feuille préalablement créée.
Option Explicit
Sub test()
Dim a, i As Long, w()
a = Sheets("Feuil1").Range("a1").CurrentRegion.Value
ReDim Preserve a(1 To UBound(a, 1), 1 To UBound(a, 2) + 1)
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 1 To UBound(a, 1)
If Not .exists(a(i, 6)) Then
.Item(a(i, 6)) = VBA.Array(a(i, 6), 1)
Else
w = .Item(a(i, 6))
w(1) = ""
.Item(a(i, 6)) = w
End If
Next
For i = 1 To UBound(a, 1)
If .exists(a(i, 6)) Then
w = .Item(a(i, 6))
a(i, 21) = w(1)
.Item(a(i, 6)) = w
End If
Next
'restitution en Feuil2
With Sheets("Feuil2").Range("a1")
.Parent.Cells.Clear
.Resize(UBound(a, 1), UBound(a, 2)).FormulaLocal = a
With .CurrentRegion
.Columns("U").SpecialCells(4).EntireRow.Delete
.Columns("U").Delete
End With
With .CurrentRegion
.Font.Name = "calibri"
.Font.Size = 10
.VerticalAlignment = xlCenter
.BorderAround Weight:=xlThin
.Borders(xlInsideVertical).Weight = xlThin
.Columns.AutoFit
End With
.Parent.Activate
End With
End With
End Sub
klin89