运行带循环的宏时,Excel挂起或冻结 [英] Excel is hanging or freezing while running macro with loops

查看:126
本文介绍了运行带循环的宏时,Excel挂起或冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个宏,其中包含宏内部的连续循环,同时运行现有已打开的Excel工作表,即使我打开新工作表也是如此;观察到同样的问题。

I am running a macro which contains the continuous loop inside the macro, while running it existing opened excel sheets are hanging and even if i open new sheet observed the same problem.

在我使用以下陈述之后,即使我不能成功。谢谢advace您的帮助。

Even i could not succeeded after I use below statements. Thanks in advace for your help.

Application.EnableEvents =假

Application.ScreenUpdating =假

Application.Calculation = xlCalculationManual&NBSP ;

Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual  

谢谢,

Ashok

推荐答案

如果你想在宏运行时使用工作表,那么你的循环深处包括

If you want to use the worksheet while the macro is running, then deep inside your loops include the

DoEvents

声明。 这将允许您(用户)在宏运行时与宏共享焦点。

statement.  This will allow you (the user) to share focus with the macro while it is running.

请注意宏将运行比它没有分享要慢一点。

Just be aware that the macro will run a little slower than it would if it did not have to share.


这篇关于运行带循环的宏时,Excel挂起或冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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