|
代码如下。。。
Sub test()
arr = Sheet1.UsedRange
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
For j = 2 To UBound(arr, 2)
s = s & arr(i, j)
Next
If Not d.exists(s) Then n = n + 1: d(s) = n
m = d(s)
For k = 1 To UBound(arr, 2)
If k <> 4 Then brr(m, k) = arr(i, k)
Next
brr(m, 4) = brr(m, 4) + arr(i, 4)
If brr(m, 4) > 1 Then brr(m, 1) = Empty
s = Empty
Next
Set d = Nothing
With Sheet2
.[a20].CurrentRegion.Clear
.[a20].Resize(, UBound(arr, 2)) = arr
.[a21].Resize(n, UBound(arr, 2)) = brr
With .[a20].CurrentRegion
.Borders.LineStyle = 1
.HorizontalAlignment = xlCenter
.Columns.AutoFit
End With
.Activate
End With
Beep
End Sub
|
|