- Sub lqxs()
- Dim Arr, i&, j&, aa, n&, m&
- Dim d, k, t, k1, t1, km$
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Sheet1.Activate
- [c3:c500].Clear
- Arr = [a1].CurrentRegion
- For i = 3 To UBound(Arr)
- km = Left(Arr(i, 1), 4)
- If Mid(Arr(i, 1), 5, 1) <> "[" Then
- d(km) = Arr(i, 1)
- Else
- d1(km) = d1(km) & i & ","
- End If
- Next
- k = d.keys: k1 = d1.keys
- t = d1.items: t1 = d.items: n = 2
- For i = 0 To UBound(k)
- n = n + 1: m = 0
- [f:f].ClearContents
- Cells(n, 3) = t1(i)
- Cells(n, 3).Font.Bold = True
- If d1.exists(k(i)) Then
- tt = d1(k(i))
- tt = Left(tt, Len(tt) - 1)
- If InStr(tt, ",") Then
- aa = Split(tt, ",")
- For j = 0 To UBound(aa)
- m = m + 1
- Cells(m, 6) = Arr(aa(j), 1)
- Next
- [f1].Resize(m, 1).Sort [f1], 1
- [f1].Resize(m, 1).Copy Cells(n + 1, 3)
- n = n + m
- Else
- n = n + 1
- Cells(n, 3) = Arr(tt, 1)
- End If
- End If
- Next
- [f:f].ClearContents
- End Sub
复制代码 |