简体   繁体   English

Excel 使用个人宏工作簿后冻结

[英]Excel freezes after using personal macro workbook

(first of all sorry for my english). (首先对不起我的英语)。 Maybe someone experienced a similar issue and could help.也许有人遇到过类似的问题并且可以提供帮助。 I wrote some VBA code for simple tasks and put all of it in a personal workbook in the XLSTART.我为简单的任务编写了一些 VBA 代码,并将其全部放在 XLSTART 的个人工作簿中。 It's quite a small workbook, not more than 200-300 lines of code and some small tables in the worksheets of the personal that the macro takes info from.这是一个相当小的工作簿,不超过 200-300 行代码和宏从中获取信息的个人工作表中的一些小表格。 The problem is that excel is starting to freeze after copying something or in the middle of writing simple formulas.问题是 excel 在复制某些内容后或在编写简单公式的过程中开始冻结。 When it freezes I need to force close it via task manager.当它冻结时,我需要通过任务管理器强制关闭它。 When I delete the personal workbook excel returns to work just fine so I know it has something to do with the personal.当我删除个人工作簿 excel 恢复正常工作时,我知道这与个人有关。 It's strange that the presence of a personal workbook in the background has that big of an effect on excel's performance.奇怪的是,背景中存在个人工作簿对 excel 的性能有如此大的影响。 Has someone encountered this issue?有人遇到过这个问题吗?

This may help or not depending on what causes your excel to hang.这可能有帮助或没有帮助,具体取决于导致 excel 挂起的原因。

Try to put these lines at the top of your code:尝试将这些行放在代码的顶部:

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

and this at the bottom:这在底部:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

This will make your macro more prioritized as excel will stop recalculating formulas between every cell update.这将使您的宏更有优先级,因为 excel 将在每次单元格更新之间停止重新计算公式。

You could also take a look at this answer How to avoid using Select in Excel VBA to see if your code can be more efficient你也可以看看这个答案How to Avoid using Select in Excel VBA看看你的代码是否可以更高效

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

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