明天使用VBA Application.ontime [英] Using VBA Application.ontime for a time tomorrow

查看:39
本文介绍了明天使用VBA Application.ontime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 application.ontime 在excel中的VBA中编写了一个计时器,该计时器会发出声音,并在到达结束时间时显示一个消息框.

I have written a timer in VBA in excel using application.ontime that makes a sound and gives a message box when an end time is reached.

当时间在同一天的晚些时候很好用,但是到第二天,计时器立即结束,因为今天已经过去了.

This works fine when the time is later in the same day, but when it goes to the next day the timer ends right away, as that time has already passed today.

例如,如果当前时间是现在的7:00 pm,而我希望计时器在明天的6:00出发,那么该计时器将立即关闭,因为今天的6:00早已过去.

E.g., if the time is currently 7:00 pm and I want the timer to go off at 6:00 am tomorrow, then the timer goes off immediately because 6:00 am has already passed today.

是否可以将日期合并到 application.ontime 调用中?我最好使用其他功能吗?

Is there any way of incorporating the date into the application.ontime call? Am I better off using some other function?

推荐答案

您可以使用:

Application.OnTime Date + 1 + Timeserial(6,0,0), "macro_name"

只要您明天早上6点之前不关闭Excel.;)

as long as you don't close Excel before 6am tomorrow. ;)

这篇关于明天使用VBA Application.ontime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆