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

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

问题描述

你好 Stackoverflow 的朋友们,

Hello Stackoverflow friends,

我想通过 VBA 插入一个公式,我为此苦苦挣扎了 1 小时:

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

我收到以下错误消息:

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

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

括号或双引号有问题吗?

Is there an issue with the brackets or double quotes?

谢谢!

推荐答案

用逗号替换分号:

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

OpenOffice 使用分号分隔函数参数,Excel 通常使用逗号,并且在以上述方式设置公式时总是使用逗号.

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天全站免登陆