在 Excel VBA 中编写公式 [英] Write a formula in Excel VBA
本文介绍了在 Excel VBA 中编写公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力在 Excel VBA 中编写公式.
I'm struggling to write a formula in Excel VBA.
这是我的代码:
Dim Formula as Range
Dim Number as Integer
Number = 1
Formula.formula = "=MAX(IF(LEFT(B7:B250,1)= & Number &, B7:B250))"
它给出了一个语法错误.
It gives a syntax error.
推荐答案
您遗漏了一些引号:
"=MAX(IF(LEFT(B7:B250,1)=" & Number & ",B7:B250))"
另外,这是一个数组公式,所以使用 .FormulaArray
而不是 .Formula
.
Also, this is an array formula so use .FormulaArray
instead of .Formula
.
这篇关于在 Excel VBA 中编写公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文