K. Robert
K. Robert

Reputation: 101

.Formula code run-time error 1004

The following code returns the above error

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

Any idea why? I have similar codes to this in the same macro but this particular one won't work.

Upvotes: 0

Views: 31

Answers (1)

user4039065
user4039065

Reputation:

Double up quotes within a quoted string.

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

There is also an alternate to "".

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

Upvotes: 1

Related Questions