|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub a()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Dim arr, temp
temp = [a1].CurrentRegion
[a1].CurrentRegion.RemoveDuplicates Columns:=Array(1, 2)
arr = [a1].CurrentRegion
[a1].Resize(UBound(temp), UBound(temp, 2)) = temp
Dim i&, s$
For i = 1 To UBound(arr)
s = arr(i, 1)
If arr(i, 2) <> "" Then d(s) = IIf(d(s) = "", arr(i, 2), d(s) & "|" & arr(i, 2))
Next
With [g1]
.CurrentRegion.ClearContents
.Resize(d.Count, 1) = Application.Transpose(d.keys)
.Offset(0, 1).Resize(d.Count, 1) = Application.Transpose(d.Items)
.Offset(0, 1).Resize(d.Count, 1).TextToColumns Destination:=.Offset(0, 1), OtherChar:="|"
End With
Set d = Nothing
End Sub |
评分
-
2
查看全部评分
-
|