|
Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, n&, r&, dte As Date, iMax&
Application.ScreenUpdating = False
dte = [F1].Value: iMax = [G1].Value
r = Cells(Rows.Count, "f").End(xlUp).Row
ar = Range("F4:G" & r).Value
br = [A1].CurrentRegion.Value
For i = 1 To UBound(ar)
ar(i, 2) = Empty: n = 0
For j = 2 To UBound(br)
If br(j, 1) > dte And br(j, 2) = ar(i, 1) Then
n = n + 1
If n > iMax Then Exit For
ar(i, 2) = ar(i, 2) + br(j, 3)
End If
Next j
Next i
[I4].Resize(UBound(ar), 2) = ar
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|