iT邦幫忙

0

VBA 定時啟動問題

  • 分享至 

  • twitterImage

function 觸發

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
海綿寶寶
iT邦大神 1 級 ‧ 2016-11-24 10:14:56
最佳解答

參考資料來源

Option Explicit
Dim alertTime
Dim timerActivate
Public Sub EventMacro()
    If Range("B17").Value >= 30 Then
        '1.Set next time job
        alertTime = Now + TimeValue("00:00:10")
        Application.OnTime alertTime, "EventMacro"
        
        '2.Your time job
        Application.StatusBar = SendOrderText("type1", "data1")
    Else
        timerActivate = False
    End If
End Sub
Public Sub StartTimer()
    alertTime = Now + TimeValue("00:00:10")
    Application.OnTime alertTime, "EventMacro"
    
    timerActivate = True
End Sub
Public Function SendOrderText(strOrderType, strOrderData)
    SendOrderText = Now
End Function
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$17" Then
        If Range("B17").Value >= 30 Then
            If timerActivate = False Then
                Call StartTimer
            End If
        End If
    End If
End Sub

我要發表回答

立即登入回答