EXCEL中如何将A列相同项所对应的B列数据按C列要求合并至D列,并且数据间用顿号隔开。
1个回答
展开全部
用代码解决,仅供参考:
Sub test()
Dim d, ar, br(), hz$, r%, c%, k%, y%
Set d = CreateObject("scripting.dictionary")
ar = Intersect([a1].CurrentRegion, [a:b])
ReDim br(1 To UBound(ar), 1 To 2)
For r = 1 To UBound(ar)
hz = ar(r, 1)
If Not d.exists(hz) Then
k = k + 1
d(hz) = k
For c = 1 To 2
br(k, c) = ar(r, c)
Next
Else
y = d(hz)
br(y, 2) = br(y, 2) & "、" & ar(r, 2)
End If
Next
[f1].Resize(k, 2) = br
Set d = Nothing
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询