Gonzalo
Gonzalo

Reputation: 1114

Insert formula in cell using VBA issue

i am having issues inserting the below formula in a cell. I doubled the " already. Any idea what i am doing wrong? Thanks a lot

Sub insert_formulas()

Worksheets("Parsing").Range("H2").Formula = "=IF(E2=""New"";OFFSET(H2,-1;0)-H2;""N/A"")"


End Sub

Replaced it for: (but still error 400)

Sub insert_formulas()

Worksheets("Parsing").Range("H2").Formula = "=IF(E2=""New"",OFFSET(H2,-1,0)-H2,""N/A"")"


End Sub

Its solved. Thanks - the above is correct.

Upvotes: 0

Views: 470

Answers (1)

Alexander Bell
Alexander Bell

Reputation: 7918

The VBA statement shown in your post (see the one marked with "...the above is correct"):

Worksheets("Parsing").Range("H2").Formula = "=IF(E2=""New"",OFFSET(H2,-1;0)-H2,""N/A"")"

contains error in OFFSET() Function: it should be corrected as following:

Worksheets("Parsing").Range("H2").Formula = "=IF(E2=""New"",OFFSET(H2,-1,0)-H2,""N/A"")"

Best regards,

Upvotes: 1

Related Questions