|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub t()
Dim arr, brr(), crr, m%, r%, c%, dic, rr%, cc%
Set dic = CreateObject("Scripting.Dictionary")
With Sheets(1)
m = .Range("a1").End(4).Row
arr = .Range("a2").Resize(m, 8)
r = 1: c = 8: rr = 2
ReDim brr(1 To m, 1 To c)
For i = 1 To m
If arr(i, 7) <> "重复" Then
For j = 1 To c
brr(r, j) = arr(i, j)
Next j
r = r + 1
End If
Next i
For i = 1 To UBound(brr)
If rr = m Then rr = i
If brr(i, 8) <> "" Then
cm = Left(Split(brr(i, 8), "(")(1), 2)
End If
If cm = "出门" And brr(i, 2) = brr(rr, 2) Then
t1 = FormatDateTime(brr(i, 4), 4)
t2 = FormatDateTime(brr(rr, 4), 4)
ti = DateDiff("s", t1, t2) / 60
If t1 > "08:30" And t1 < "11:30" And ti >= 10 Then
dic(brr(i, 1) & "|" & brr(i, 2) & "|" & brr(i, 3)) = dic(brr(i, 1) & "|" & brr(i, 2) & "|" & brr(i, 3)) + 1
End If
End If
rr = rr + 1
Next
Sheet1.[k1].Resize(UBound(brr), UBound(brr, 2)) = brr
ReDim crr(1 To dic.Count, 1 To 4)
cc = 1
For Each k In dic.keys
p = Split(k, "|")
For i = 0 To UBound(p)
crr(cc, i + 1) = p(i)
Next i
crr(cc, 4) = dic(k)
cc = cc + 1
Next k
Sheet2.[f1].Resize(UBound(crr), UBound(crr, 2)) = crr
End With
Set dic = Nothing
End Sub
|
|