§Ú§Ë¦n¤F¡Aì¨Ó¬On¶K¦b¨Ó·½¨ºÃä¡AµM«á§Ú§âWith Sheet3®³±¼¤F
Sub Ex()
Set dic = CreateObject("Scripting.Dictionary")
Set dicn = CreateObject("Scripting.Dictionary")
For Each a In Sheets("sheet3").Range([H2], [H65536].End(xlUp))
dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) + a.Offset(, 2)
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) + 1
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
If a <> "" Then
mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))
If dicn(a & a.Offset(, 1)) = 1 Then
a.Offset(, 5) = Val(dic(a & a.Offset(, 1)))
Else
a.Offset(, 5) = mytime
dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) - 1
dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) - mytime
End If
End If
Next
End Sub