|
Sub qs()
Dim arr, i, dic, sj
sj = CDate(Sheet2.[k2].Value)
arr = Sheet1.Range("a4").CurrentRegion
ReDim brr(1 To UBound(arr), 1 To 6)
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 4) & "|" & arr(i, 5) & "|" & arr(i, 6)
If CDate(arr(i, 3)) = sj Then
If Not dic.exists(s) Then
m = m + 1
dic(s) = m
brr(m, 1) = m
For j = 1 To 3
brr(m, j + 1) = arr(i, j + 3)
Next
brr(m, 5) = arr(i, 8)
Else
r = dic(s)
brr(r, 5) = brr(r, 5) + arr(i, 8)
End If
End If
Next
With Sheet2
.Range("a3").Offset(1).Resize(1000, 6).ClearContents
.Range("a4").Resize(m, 6) = brr
End With
End Sub |
|