|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim arr, i, j, m, n, t
arr = [a1].CurrentRegion
ReDim brr(1 To 2 * UBound(arr, 1) + 1, 1 To 1)
For j = 1 To UBound(arr, 2)
For i = 2 To UBound(arr, 1)
If Len(arr(i, j)) = 0 Then Exit For
m = m + 1: brr(m, 1) = arr(i, j)
Next i, j
For i = 1 To m - 1
For j = i To m
If brr(i, 1) > brr(j, 1) Then
t = brr(i, 1): brr(i, 1) = brr(j, 1): brr(j, 1) = t
End If
Next j, i
For i = 1 To m
For j = i To m
If brr(j, 1) <> brr(j + 1, 1) Then
If j > i Then n = n + 1: brr(n, 1) = brr(i, 1)
i = j: Exit For
End If
Next j, i
With [c2]
.Resize(Rows.Count - 1).ClearContents
If n > 0 Then .Resize(n) = brr
End With
End Sub |
|