excel表中b列很多相同名字,a列是电话号码,如何把a列的电话号码对应到b列同名后的一行
2个回答
2016-12-22
展开全部
Sub test()
Dim d, Ar, Br, t, i%, j%
Set d = CreateObject("scripting.dictionary")
Ar = [a1].CurrentRegion
For i = 1 To UBound(Ar)
d(Ar(i, 2)) = d(Ar(i, 2)) & "," & Ar(i, 1)
Next
[d:k] = ""
[d1].Resize(d.Count, 1) = Application.Transpose(d.keys)
t = d.items
For j = 0 To UBound(t)
Br = Split(Mid(t(j), 2), ",")
Cells(j + 1, "e").Resize(1, UBound(Br) + 1) = Br
Next
Set d = Nothing
End Sub
假定数据在A,B两列,从a1单元格开始,从D列开始得到结果。
追问
能否详细说明一下吗具体使用方法。
追答
将你的数据粘贴在此表上,另外你百度一下,如何创建VBA
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询