.Formula代码运行时错误1004

时间:2018-03-05 09:13:33

标签: excel excel-vba runtime-error vba

以下代码返回上述错误

Dim RAWfRange As Range
Dim Loc1 As Range

Set Loc1 = Range("F1")

Set RAWfRange = Range(Loc1, Loc1.End(xlDown))

Loc1.Formula = "=IFERROR(VLOOKUP(A1,Report!B:O,14,FALSE),"")" ' <--- Error on this line
Loc1.AutoFill Destination:=RAWfRange

知道为什么吗?我在同一个宏中有类似的代码,但这个特殊的代码不会起作用。

1 个答案:

答案 0 :(得分:1)

在引用的字符串中加倍引号。

Loc1.Formula = "=IFERROR(VLOOKUP(A1,Report!B:O,14,FALSE),"""")"

还有""的替代。

Loc1.Formula = "=IFERROR(VLOOKUP(A1,Report!B:O,14,FALSE),TEXT(,))"
相关问题