|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
希望能够帮助到你。
仅针对你当前的情况:
Sub byWanao()
Dim i&, j&, k&, jg&, m1&, m2&
k = 3
For i = 3 To Cells(Rows.Count, "f").End(xlUp).Row
m1 = 0
m2 = 0
For j = k To Cells(Rows.Count, "a").End(xlUp).Row
If Hour(Cells(j, "a")) = Hour(Cells(i, "f")) And Minute(Cells(j, "a")) = Minute(Cells(i, "f")) Then
If InStr(Cells(j, "d"), "买") Then
m1 = m1 + Cells(j, "c")
ElseIf InStr(Cells(j, "d"), "卖") Then
m2 = m2 + Cells(j, "c")
End If
Else
Cells(i, "g") = Cells(j - 1, "b")
Cells(i, "h") = m1
Cells(i, "i") = m2
k = j
Exit For
End If
Next
Next
End Sub |
|