【问题标题】:VBA - Due Date with Hours and Minutes?VBA - 带有小时和分钟的截止日期?
【发布时间】:2016-02-03 21:16:47
【问题描述】:

假设我想要一个 msgbox 弹出一个小时后发生的事情,这将如何完成?

我在想一些事情:

MyLimit = Now

If .Value = MyLimit Then
msgbox "Do that thing cause it is due right now"

MyLimit = Date

If .Value = MyLimit Then
msgbox "Do that thing cause it is due right now"

并让公式引用日期格式为“m/d/yy h:mm AM/PM”的单元格

类似的东西不起作用,我想知道为什么。

【问题讨论】:

    标签: excel vba date time


    【解决方案1】:

    试试 Application.OnTime 方法

    Sub setAlarm()
        Application.OnTime Range("deadline").Value - TimeValue("01:00:00"), "my_Procedure"
    End Sub
    
    Sub my_Procedure()
        MsgBox "Do that thing cause it is due right now"
    End Sub
    

    消息框在截止日期前一小时弹出

    【讨论】:

    • 谢谢你,我明天回去工作后测试一下,如果可以的话,告诉你:) 到目前为止看起来不错,我不知道这个方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-06
    • 2021-08-19
    • 2011-04-14
    相关资源
    最近更新 更多