Option Explicit
Sub test()
Dim arr, i, j, n, brr, t, num
arr = [a1].CurrentRegion
brr = arr: n = 1
For i = 2 To UBound(arr, 1)
num = arr(i, 2)
If InStr(num, Space(1)) Then num = Val(Split(num)(0))
If num > 10 Then
n = n + 1
brr(n, 1) = arr(i, 1): brr(n, 2) = arr(i, 2)
Else
For j = i - 1 To 2 Step -1
num = arr(j, 2)
If InStr(num, Space(1)) Then num = Val(Split(num)(0))
If num > 10 Then t = arr(j, 1): Exit For
Next
If j > 1 Then
For j = i + 1 To UBound(arr, 1)
num = arr(j, 2)
If InStr(num, Space(1)) Then num = Val(Split(num)(0))
If num > 10 Then Exit For
Next
If j < UBound(arr, 1) + 1 Then
If (arr(j, 1) - t) * 24 * 60 < 120 Then '分钟之差
n = n + 1
brr(n, 1) = arr(i, 1): brr(n, 2) = arr(i, 2)
End If
End If
End If
End If
Next
With [d1]
.Resize(Rows.Count, 2).ClearContents
.Resize(n, 2) = brr
End With
End Sub |