Private Sub CommandButton1_Click()
Dim d As Object, arr, i%, j%, s$, s1$, sp
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet1.Range([a2], [b2].End(4))
For i = 1 To UBound(arr)
s = arr(i, 2): s1 = arr(i, 1)
If InStr(s, "、") = 0 And Not d.exists(s) Then d.Add s, s1
sp = Split(s, "、")
For j = 0 To UBound(sp)
If Not d.exists(sp(j)) Then
d.Add sp(j), s1
Else
d(sp(j)) = IIf(InStr(d(sp(j)), s1) = 0, d(sp(j)) & "、" & s1, d(sp(j)))
End If
Next j
Next i
[d2].Resize(d.Count, 1) = Application.Transpose(d.keys)
[e2].Resize(d.Count, 1) = Application.Transpose(d.items)
Set d = Nothing
End Sub作者: 偉婕 時間: 2010-10-8 16:21