使用VBA在Excel单元格中编写公式 [英] Write a formula in an Excel Cell using VBA
本文介绍了使用VBA在Excel单元格中编写公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用VBA将公式写入Excel中的单元格。
我的问题是,当我在我的公式中使用分号(;
)时,我收到一个错误:
I'm trying to use VBA to write a formula into a cell in Excel.
My problem is that when I use a semicolon (;
) in my formula, I get an error:
错误1004
Error 1004
我的宏是以下内容:
Sub Jours_ouvres()
Dim Feuille_Document As String
Feuille_Document = "DOCUMENT"
Application.Worksheets(Feuille_Document).Range("F2").Formula = "=SUM(D2;E2)"
End Sub
推荐答案
您可以尝试使用FormulaLocal属性而不是Formula。那么分号应该工作。
You can try using FormulaLocal property instead of Formula. Then the semicolon should work.
这篇关于使用VBA在Excel单元格中编写公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文