- Sub 按钮1_Click()
- Dim brr()
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- arr = [a1].CurrentRegion
- a = 1
- For j = 2 To UBound(arr)
- If d.exists(arr(j, 1)) Then
- r = d(arr(j, 1))
- brr(2, r) = 1 + brr(2, r)
- brr(3, r) = brr(3, r) & j & ","
- brr(4, r) = arr(j, 6) + brr(4, r)
- Else
- ReDim Preserve brr(1 To 5, 1 To a)
- brr(1, a) = arr(j, 1)
- brr(2, a) = 1
- brr(3, a) = j & ","
- brr(4, a) = arr(j, 6)
- brr(5, a) = a
- d(arr(j, 1)) = a
- a = a + 1
- End If
- Next j
- For j = 1 To a - 1
- d.RemoveAll
- crr = Split(brr(3, j), ",")
- For i = 0 To UBound(crr) - 1
- d(arr(crr(i), 5)) = ""
- Next i
- brr(3, j) = d.Count
- Next j
-
- For j = 1 To a - 1
- For i = j + 1 To a - 1
- If brr(4, j) < brr(4, i) Then
- For l = 1 To 4
- tmp = brr(l, i)
- brr(l, i) = brr(l, j)
- brr(l, j) = tmp
- Next l
- End If
- Next i
- Next j
- [j2].Resize(a - 1, 5) = WorksheetFunction.Transpose(brr)
- Columns("j:j").Replace " ", ""
- For j = 0 To 9
- Columns("j:j").Replace j, ""
-
- Next j
- Application.ScreenUpdating = True
-
- End Sub
复制代码 |