¥»©«³Ì«á¥Ñ color790 ©ó 2010-9-1 14:16 ½s¿è
¬°¤°»ò°õ¦æ¤F,¤@ÂI¤ÏÀ³¤]¨S¦³
½Ð°Ýþ¸Ì»Ýn×§ï ?
Sub aa()
j = 2
For i = 2 To 5002
If Cells(i, 2) = TimeValue("09:30:00") And Cells(i, 1) = Cells(j, 16) Then 'aÄæ¬°¤é´Á,bÄæ¬°®É¶¡
x = Application.Max(Range(Cells(i - 2, 4), Cells(i, 4)))
Z = Application.Min(Range(Cells(i - 2, 5), Cells(i, 5)))
Do Until Cells(i, 4) > x + 30 And Cells(i, 1) = Cells(j, 16) Or Cells(i, 5) < Z
i = i + 1
Loop
If Cells(i, 5) < Z Then
Set y = Cells(i, 5)
Else
Set y = Cells(i, 4)
End If
y.Offset(, 7) = y - x
End If
j = j + 1
Next
End Sub |