- 帖子
- 764
- 主題
- 254
- 精華
- 0
- 積分
- 1031
- 點名
- 0
- 作業系統
- windows 11
- 軟體版本
- OFFICE2021
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2011-5-30
- 最後登錄
- 2025-5-7
|
3#
發表於 2013-10-13 09:58
| 只看該作者
本帖最後由 t8899 於 2013-10-13 10:08 編輯
回復 t8899
試試看
GBKEE 發表於 2013-10-12 16:25 
謝謝指導,vb 正學習當中,多日無人回應,小弟想出的簡單的方法,提供參考
Public Runtime
Sub a123()
If Range("U1").Value <> 1 Then
On Error Resume Next
Application.OnTime EarliestTime:=TimeValue(Runtime), _
Procedure:="a123", Schedule:=False
Cells(15, 9).Interior.ColorIndex = 2 '退出色彩還原
Range("u1").Value = 1
Range("z1").Value = 1
Exit Sub
On Error GoTo 0
End If
zzzzz
If Range("V14") = 1 Then mytime = "00:01:00"
If Range("V14") = 2 Then mytime = "00:02:00"
If Range("V14") = 3 Then mytime = "00:00:30"
If Range("V14") = 4 Then mytime = "00:00:15"
If Range("z1").Value = 1 Then
Cells(15, 9).Interior.ColorIndex = 8 '執行中變色
Runtime = Now + TimeValue(mytime)
Range("I15").Value = Format(Runtime, "hh:mm:ss")
Range("z1").Value = 2
Else
Runtime = Range("I15").Value + TimeValue(mytime)
Range("I15").Value = Format(Runtime, "hh:mm:ss")
End If
Application.OnTime Runtime, "Sheet6.a123"
End Sub |
|