|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub zz()
Dim d, arr
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet1.Range("A1:B" & Sheet1.Range("B1").End(xlDown).Row)
For i = 1 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
d(arr(i, 1)) = arr(i, 2)
Else
If InStr(d(arr(i, 1)), "," & arr(i, 2)) = 0 Then '这里用 "," & arr(i, 2)来测试就可以了。
d(arr(i, 1)) = d(arr(i, 1)) & "," & arr(i, 2)
End If
End If
Next
Sheet1.Range("E1").Resize(d.Count, 2) = Application.Transpose(Array(d.keys, d.items))
End Sub
|
|