|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub lqxs()
- Dim Arr, i&, j&, aa, Brr
- Dim d, k, t
- Set d = CreateObject("Scripting.Dictionary")
- Sheet1.Activate
- Arr = [c1].CurrentRegion
- [c9:e500].Clear
- For i = 1 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 UBound(Arr, 2))
- d.RemoveAll
- For i = 0 To UBound(k)
- t(i) = Left(t(i), Len(t(i)) - 1)
- Brr(i + 1, 1) = k(i)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- For j = 0 To UBound(aa)
- x = Left(Arr(aa(j), 2), 4)
- If Brr(i + 1, 2) = "" Then
- If Not d.exists(x) Then
- d(x) = ""
- Brr(i + 1, 2) = x
- End If
- Else
- If Not d.exists(x) Then
- d(x) = ""
- Brr(i + 1, 2) = Brr(i + 1, 2) & "/" & x
- End If
- End If
- Brr(i + 1, 3) = Brr(i + 1, 3) + Arr(aa(j), 3)
- Next
- Else
- End If
- d.RemoveAll
- Next
- [c9].Resize(UBound(Brr), UBound(Brr, 2)) = Brr
- [c9].Resize(UBound(Brr), UBound(Brr, 2)).Borders.LineStyle = 1
- End Sub
复制代码 |
|