Salut patrick1957,
On va arrêter de pinailler 8)
Restitution en Feuil2
Option Explicit
Sub test()
Dim a, w(), t As Byte, i As Long, n As Long, x, y
With Sheets("Feuil1").Cells(1).CurrentRegion
a = .Value
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For t = 1 To 2
For i = 1 To UBound(a, 1)
If a(i, t) <> 0 Then
If Not .exists(a(i, t)) Then
ReDim w(1 To 3)
ReDim tablo(1 To 2, 1 To 1)
Else
w = .Item(a(i, t))
tablo = w(3)
End If
w(t) = w(t) + 1
If UBound(tablo, 2) < Application.Max(w(1), w(2)) Then
ReDim Preserve tablo(1 To 2, 1 To UBound(tablo, 2) + 1)
End If
tablo(t, w(t)) = a(i, t)
w(3) = tablo
.Item(a(i, t)) = w
End If
Next
Next
x = .keys: y = .items
End With
End With
Application.ScreenUpdating = False
'Restitution et mise en forme
With Sheets("Feuil2").Cells(1)
.Parent.Cells.Clear
For i = 0 To UBound(x)
With .Offset(n).Resize(UBound(y(i)(3), 2), UBound(y(i)(3), 1))
.Value = Application.Transpose(y(i)(3))
.BorderAround Weight:=xlThin
n = n + .Rows.Count
End With
Next
With .CurrentRegion
.Borders(xlInsideVertical).Weight = xlThin
.Font.Name = "calibri"
.Font.Size = 10
.VerticalAlignment = xlCenter
'.Columns.AutoFit
End With
.Parent.Activate
End With
Application.ScreenUpdating = True
End Sub
klin89