|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST5()
Dim ar, br, i&, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
ar = Range("K3", Cells(Rows.Count, "L").End(xlUp)).Value
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 1)) Then
dic(ar(i, 1)) = ar(i, 2)
Else
dic(ar(i, 1)) = dic(ar(i, 1)) & " " & ar(i, 2)
End If
Next i
With Range("P3", Cells(Rows.Count, "P").End(xlUp))
ar = .Value
For i = 2 To UBound(ar)
If dic.exists(ar(i, 1)) Then
br = Split(dic(ar(i, 1)))
.Cells(i, 2).Resize(UBound(br) + 1) = Application.Transpose(br)
End If
Next i
End With
Set dic = Nothing
Beep
End Sub
|
|