|
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, dic As Object, vKey
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = [A2:A14].Value
For i = 1 To UBound(ar)
dic.RemoveAll
For j = 1 To Len(ar(i, 1))
dic(Mid(ar(i, 1), j, 1)) = dic(Mid(ar(i, 1), j, 1)) + 1
Next j
br = dic.keys
For Each vKey In dic.keys
If dic(vKey) > 1 Then
ReDim Preserve br(UBound(br) + 1)
br(UBound(br)) = Right(vKey + 5, 1)
Exit For
End If
Next
bSort1 br, 0, UBound(br)
ar(i, 1) = Join(br, "")
Next i
With [n2].Resize(UBound(ar))
.NumberFormatLocal = "@"
.Value = ar
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
Function bSort1(ByRef ar, ByVal iFirst&, ByVal iLast&, _
Optional ByVal isOrder As Boolean = True)
Dim i&, j&, vTemp
For i = iFirst To iLast - 1
For j = iFirst To iLast + iFirst - 1 - i
If ar(j) <> ar(j + 1) Then
If ar(j) < ar(j + 1) Xor isOrder Then
vTemp = ar(j)
ar(j) = ar(j + 1)
ar(j + 1) = vTemp
End If
End If
Next j
Next i
End Function
|
|