Excel - 使用VBA插入公式 [英] Excel - Inserting formula with VBA

查看:234
本文介绍了Excel - 使用VBA插入公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Stackoverflow的朋友,



我正在努力一个小时,我想通过VBA插入一个公式:


$ b $公式== IFERROR(VLOOKUP(Q& j&; Table1 [#All]; 2; FALSE);)
ThisWorkbook.Worksheets(Sheet1)。Cells(j,AE)。FormulaArray = Formula

我收到以下错误消息:



运行时错误'1004' - 应用程序定义或对象定义的错误



括号或双引号有问题吗?



谢谢!

解决方案

用逗号替换分号:

  Formula == IFERROR(VLOOKUP(Q& j &,Table1 [#All],2,FALSE),)

OpenOffice使用分号分隔函数参数,Excel通常使用逗号,而始终在以上述方式设置公式时使用逗号。


Hello Stackoverflow friends,

I am struggling for 1 hour with a formula I would like to insert via VBA:

Formula = "=IFERROR(VLOOKUP(Q" & j & ";Table1[#All];2;FALSE);"""")"
ThisWorkbook.Worksheets("Sheet1").Cells(j, "AE").FormulaArray = Formula

I get the following error message:

Run-time error '1004' - Application-defined or object-definied error

Is there an issue with the brackets or double quotes?

Thanks!

解决方案

Replace the semicolons with commas:

Formula = "=IFERROR(VLOOKUP(Q" & j & ",Table1[#All],2,FALSE),"""")"

OpenOffice uses semicolons to separate function parameters, Excel normally uses commas, and always uses commas when setting formulas in the above fashion.

这篇关于Excel - 使用VBA插入公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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