|
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, n&, r&, dic As Object, vKey, iRowSize&
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
r = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
ar = Range("F12:AS" & r).Value
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
For j = 1 To UBound(ar, 2)
dic.RemoveAll: n = 0
For i = 1 To UBound(ar)
If Len(ar(i, j)) Then dic(ar(i, j)) = dic(ar(i, j)) + 1
Next i
For Each vKey In dic.keys
If dic(vKey) > 1 Then
n = n + 1
br(n, j) = vKey
End If
Next
If n > iRowSize Then iRowSize = n
Next j
[AU12].Resize(iRowSize, UBound(br, 2)) = br
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|