让 Excel 从 VBA 中刷新工作表上的数据 [英] Getting Excel to refresh data on sheet from within VBA

查看:105
本文介绍了让 Excel 从 VBA 中刷新工作表上的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Excel 中获取电子表格数据以在 VBA 中重新计算自身,而不需要仅仅更改单元格值?

How do you get spreadsheet data in Excel to recalculate itself from within VBA, without the kluge of just changing a cell value?

推荐答案

以下几行代码可以解决问题:

The following lines will do the trick:

ActiveSheet.EnableCalculation = False  
ActiveSheet.EnableCalculation = True  

.Calculate() 方法不适用于所有函数.我在带有附加数组函数的工作表上对其进行了测试.我使用的生产表非常复杂,我不想测试 .CalculateFull() 方法,但它可能有效.

The .Calculate() method will not work for all functions. I tested it on a sheet with add-in array functions. The production sheet I'm using is complex enough that I don't want to test the .CalculateFull() method, but it may work.

这篇关于让 Excel 从 VBA 中刷新工作表上的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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