- Sub 删除重复()
- Dim arr, brr, i, j, k, r, d
- Set d = CreateObject("scripting.dictionary")
- With Sheet3
- r = .Cells(Rows.Count, 4).End(xlUp).Row
- c = .Cells(4, Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(r, c)
- End With
- ReDim brr(1 To UBound(arr), 1 To c)
- For i = 5 To UBound(arr)
- sa = arr(i, 5)
- If Not d.exists(sa) Then
- n = n + 1
- For j = 1 To UBound(arr, 2)
- brr(n, j) = arr(i, j)
- Next
- d(sa) = n
- Else
- m = d(sa)
- brr(m, 12) = brr(m, 12) + arr(i, 12)
- End If
- Next
- Stop
- With Sheet2
- .Range("a5").Resize(r - 3, c).Clear
- .[a5].Resize(n, c) = brr
- .[a5].Resize(n, c).Borders.LineStyle = 1
- End With
- End Sub
复制代码 |