ThisWorkbook不保留全局变量值取消ontime() [英] ThisWorkbook not holding global variable value to cancel ontime()

查看:148
本文介绍了ThisWorkbook不保留全局变量值取消ontime()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下链接:



http://www.ozgrid.com/Excel/run-macro-on-time.htm



存储通过 ontime 调用函数的时间,然后取消它。但是,在最后一次存储之后,我调用 ontime()然后我的函数关闭。问题是我刚刚存储的时间超出了范围,而chanegs为空。所以使用上面的链接,我说一旦$ code> RunOnTime()已经完成,dTime的值是空的,因此当我调用 CancelOnTime() 它不工作。我在这个例子中宣布了dTime。除了我在ThisWorkbook中,一切都一样。



任何人都可以建议?

解决方案>

在示例中,变量 dTime 被声明为 Public 。事实上,它不需要是因为只有 RunOnTime()访问它,但是可以使用您编写的函数访问它。 CancelOnTime()不依赖于变量。



我想你可能会将自己与Watch混淆。要查看公共变量,您将上下文设置为所有过程 - 所有模块。


I am using the below link:

http://www.ozgrid.com/Excel/run-macro-on-time.htm

to store the time at which I call a function via ontime and then cancel it. However, after I store the last time, I call ontime() then my function closes. The problem is the time I have just stored goes out of scope and chanegs to empty. So using the link above, I am saying that once RunOnTime() has finished, the value of dTime is empty and therefore when I call CancelOnTime() it does not work. I declared dTime just as in the example. Everything is the same except I am in ThisWorkbook.

Can anyone advise?

解决方案

In the example, the variable dTime is declared as Public. In fact, it doesn't need to be because only RunOnTime() accesses it, but it's useful to be able to access it with a function you wrote. CancelOnTime() doesn't depend on the variable.

I think you may be confusing yourself with Watch. To watch a public varaiable, you set the context to All Procedures - All Modules.

这篇关于ThisWorkbook不保留全局变量值取消ontime()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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