|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST5()
Dim ar, br, i&, j&, iColSize&, dic As Object, strKey$
Set dic = CreateObject("Scripting.Dictionary")
ar = [A2].CurrentRegion.Value
For i = 2 To UBound(ar)
strKey = ar(i, 1) & "," & ar(i, 2)
dic(strKey) = dic(strKey) & "," & ar(i, 3)
Next i
ReDim ar(1 To dic.Count, 1 To UBound(ar) + 2)
For i = 0 To dic.Count - 1
br = Split(dic.keys()(i), ",")
ar(i + 1, 1) = br(0): ar(i + 1, 2) = br(1)
br = Split(dic.items()(i), ",")
For j = 1 To UBound(br)
ar(i + 1, j + 2) = br(j)
Next j
If 2 + UBound(br) > iColSize Then iColSize = 2 + UBound(br)
Next i
[E10].Resize(UBound(ar), iColSize) = ar
Set dic = Nothing
Beep
End Sub
|
|