|
- Sub lqxs()
- Dim Arr, i&, Brr, j&, aa, n&
- Dim d, k, t
- Set d = CreateObject("Scripting.Dictionary")
- Sheet2.Activate
- [a2:c5000].ClearContents
- Arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- d(Arr(i, 1)) = d(Arr(i, 1)) & i & ","
- Next
- k = d.keys: t = d.items
- ReDim Brr(1 To d.Count, 1 To 3)
- For i = 0 To UBound(k)
- t(i) = Left(t(i), Len(t(i)) - 1)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- n = n + 1
- Brr(n, 1) = k(i)
- For j = 0 To UBound(aa)
- If j = 0 Then
- Brr(n, 2) = Arr(aa(j), 2): Brr(n, 3) = Arr(aa(j), 3)
- Else
- Brr(n, 2) = Brr(n, 2) & "、" & Arr(aa(j), 2): Brr(n, 3) = Brr(n, 3) + Arr(aa(j), 3)
- End If
- Next
- Else
- n = n + 1
- Brr(n, 1) = k(i): Brr(n, 2) = Arr(t(i), 2): Brr(n, 3) = Arr(t(i), 3)
- End If
- Next
- [a2].Resize(n, 3) = Brr
- End Sub
复制代码 |
|