|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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 |
|