|
原帖由 albert3210 于 2011-2-5 15:34 发表
如下,有下面这样的表格
A列 B列
AA C1
BB C2
AB C3
AA C1
AA C4
BB C5
要变成下面这样的样子
A列 B列
AA C1 C1 C4
BB C2 C5
AB C3
上次也问过类似的问 ...
Sub Macro1()
Dim d As Object, arr, i&
arr = [a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
If Not d.Exists(arr(i, 1)) Then
m = m + 1
d(arr(i, 1)) = m
arr(m, 1) = arr(i, 1)
arr(m, 2) = arr(i, 2)
Else
arr(d(arr(i, 1)), 2) = arr(d(arr(i, 1)), 2) & " " & arr(i, 2)
End If
Next
[a1].CurrentRegion.ClearContents
[a1].Resize(m, 2) = arr
End Sub |
评分
-
1
查看全部评分
-
|