vba 计算数组公式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27590768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 05:36:15  来源:igfitidea点击:

Evaluate an Array Formula

excelexcel-vbavba

提问by Gary's Student

I can evaluate a normal Excel formula within VBAlike:

我可以在VBA 中评估一个普通的 Excel 公式,例如:

Sub dural()
    MsgBox Evaluate("SUM(A1:A10)")
End Sub

How can I evaluate an array formula??

如何评估数组公式?

回答by Rusan Kax

As suggested by L42, you only have to use the string variant of Evaluateto get it to work with array formulas.
For instance, does

正如L42所建议的,您只需要使用 of 的字符串变体Evaluate即可使其与数组公式一起使用。
例如,是否

Sub dural()
  MsgBox Evaluate("SUM(A1:A10)")
  MsgBox Evaluate("=SUM(G5:G10-F5:F10)")
  MsgBox [=SUM(G5:G10-F5:F10)]
  MsgBox [Sum(G5:G10-F5:F10)]
End Sub

work for you (with appropriate values in G5:G10and F5:F10)?
Some further information is here.

为您工作(在G5:G10和 中具有适当的值F5:F10)?
一些进一步的信息是here