Excel自动计算设置
我在“Microsoft Office Excel 2007”中有一个复杂的项目,它使用了大量的 UDF。通过 Workbook_Open 事件中的 VBA,我将 Excel 自动计算设置为“关闭”,并策略性地设置 计算 方法,以便在需要时手动计算单元格,这样 UDF 就不会无意中执行重新计算。
如果该工作簿是 Excel 实例中唯一打开的工作簿(或第一个打开的),则一切工作正常。仅当它在另一个工作簿(在同一实例内)打开时,我的项目才会从FIRST工作簿继承自动计算设置,并对我的 UDF 执行无休止的计算。放置在 Workbook_Open 事件中的禁用代码在 UDF 完成计算之前不会执行(这可能需要很长时间)。仅当我的项目不是第一个打开的项目时,才会发生这种情况。
通过http://www.decisionmodels.com/calcsecretse.htm,我发现它是Excel 的性质是在执行 Workbook_Open 事件之前执行计算过程。
因此,我的问题显然与在打开自动计算的情况下打开另一个工作簿之后打开的项目有关:
- 如何强制我的项目禁用自动计算 没有它首先执行重新计算(记住,仅问题 当项目不是第一个打开的项目时发生,因为它将 遵循以前打开的工作簿中的设置)或...
- 如何在另一个实例中打开项目(双击时)以避免 继承以前工作簿的自动计算设置。
无论哪种方式,我寻求的答案是打开项目而不先执行计算。
谢谢
I have a complex project in `Microsoft Office Excel 2007' which utilises a large number of UDFs. Through VBA in a Workbook_Open Event, I set Excel Automatic calculation to OFF and a strategically placed Calculate method to manually calculate the cells whenever I need it so that the UDF doesn't perform recalculation unintentionally.
If the workbook is the ONLY one opened (or the first to open) in an Excel instance, everything works perfect. Only when it's opened AFTER another workbook (within the same instance), my project will inherit the Automatic calculation setting from the FIRST workbook and perform endless calculation on my UDFs. The disable code placed in the Workbook_Open event isn't executed until the UDF finishes the calculation (which can take forever). This only happens if my project is NOT the one opened first.
Through http://www.decisionmodels.com/calcsecretse.htm, I discover that it is the nature of Excel to perform the calculation process BEFORE the Workbook_Open event is executed.
So the question I have obviously relates to the project being opened AFTER another workbook is opened with automatic calculation turned ON:
- How do I force my project to disable automatic calculation
without it performing recalculation first (remember, problem only
occurs when the project not the first one to be opened since it will
follow settings from previously opened workbook) OR... - How do I get the project to open in ANOTHER INSTANCE (when double clicked) to avoid
inheriting automatic calculation setting from the previous workbook.
Either way, the answer I'm seeking is for the project to open without performing the calculation first.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种方法是使用不同的工作簿 (Opener.xls) 来启动打开 UDF 工作簿 (udf.xls)
Opener.xls 中的 Workbook_Open 代码
- 将计算设置为手动
- 打开 udf.xls
One way is to use a different workbook (Opener.xls) to initiate opening the UDF workbook (udf.xls)
in Opener.xls the Workbook_Open code
- sets calculation to manual
- opens udf.xls
在您的问题中,我不认识您用于更改和继承该选项到工作簿的方式,但我将其作为解决方案回答:
使用 VBA 并运行 VBA 宏,只要您需要,即可更改活动工作表的该选项计算;像这样使用它:
以您可能需要的另一种方式,您可以阅读 MSDN 文章的这一部分。
In your question I don't recognize the way you use to change and inherit that option to your workbooks, But I answer it as a solution:
Use VBA and running VBA macros to change that option for just your active sheet as soon as you need to calculate; by using it like this:
In another ways that may you need, you can read this part of MSDN article.