|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim OP, ST As Date, Ar, Br, I&, J&, K&, Cr
- Sheet3.Cells.ClearContents
- OP = Sheet2.Range("b1"): ST = Sheet2.Range("D1")
- Ar = Sheet1.Range("a1").CurrentRegion
- ReDim Br(1 To UBound(Ar), 1 To UBound(Ar, 2))
- For I = 2 To UBound(Ar)
- If Ar(I, 1) = OP Then
- If Ar(I, 11) >= ST And Ar(I, 13) <= (ST + TimeValue("08:00:00")) Then
- K = K + 1
- For J = 1 To UBound(Ar, 2)
- Br(K, J) = Ar(I, J)
- Next
- End If
- End If
- Next
- Cr = Sheet1.Range("a1:q1")
- Sheet3.Range("a1").Resize(1, 17) = Cr
- Sheet3.Range("a2").Resize(K, UBound(Ar, 2)) = Br
- End Sub
复制代码 |
|