简体   繁体   English

如何在 vba 中每秒多次运行宏?

[英]How can I run a macro multiple times per second in vba?

I'm currently trying to run a macro around five times per second using the Application.OnTime but it doesn't work with times less than a second.我目前正在尝试使用 Application.OnTime 每秒运行大约五次宏,但它在不到一秒的时间内不起作用。 I know excel can handle my macro that many times as I've assigned it to a key and held it down.我知道 excel 可以多次处理我的宏,因为我已经将它分配给一个键并按住它。 So is there any other way I can run my macro multiple times per second?那么有没有其他方法可以每秒多次运行我的宏?

Thanks a lot.非常感谢。

Interval = 0.2
CurrentTime = Timer

Do While True
    If Timer > CurrentTime + Interval Then

        'Write your code here.
        
        Current = Timer
    End If
    DoEvents
Loop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM