|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST6()
Dim ar, br, cr, i&, j&, r&, c&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion.Value
ReDim br(1 To UBound(ar), 1 To UBound(ar))
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 1)) Then
r = r + 1
dic(ar(i, 1)) = Array(r, 1)
br(r, 1) = ar(i, 1)
End If
cr = dic(ar(i, 1)): cr(1) = cr(1) + 1
br(cr(0), cr(1)) = ar(i, 2)
If cr(1) > c Then c = cr(1)
dic(ar(i, 1)) = cr
Next i
[D2].Resize(r, c) = br
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|