- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
4#
發表於 2010-8-29 06:39
| 只看該作者
回復 3# color790
股票不太懂- Sub aa()
- With Sheet1
- For j = 2 To .Cells(Rows.Count, "P").End(xlUp).Row
- For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
- If .Cells(i, "B") = TimeValue("9:30:00") And .Cells(i, "A") = .Cells(j, "P") 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
- Next
- Next
- End With
- End Sub
複製代碼 |
|