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 doublon()
Dim doub As Range
Dim table() As String
Dim flag As Boolean
With Worksheets("Feuil3")
Set doub = .Range("D1")
ReDim table(1 To 2, 1 To 1)
table(1, 1) = doub
table(2, 1) = 1
For i = 1 To .Columns(4).Find("*", , , , , xlPrevious).Row - 1
flag = True
For j = LBound(table, 2) To UBound(table, 2)
If doub.Offset(i, 0) = table(1, j) Then
table(2, j) = table(2, j) + 1
flag = False
Exit For
End If
Next j
If flag Then
ReDim Preserve table(1 To 2, 1 To (UBound(table, 2) + 1))
table(1, UBound(table, 2)) = doub.Offset(i, 0)
table(2, UBound(table, 2)) = 1
End If
Next i
End With
With Worksheets("Feuil4")
For i = LBound(table, 2) To UBound(table, 2)
.Range("A1").Offset(i, 0) = table(1, i)
.Range("A1").Offset(i, 1) = table(2, i)
Next i
End With
End Sub |
Partager