0

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.

4
  • 1
    You need to use commas, not semicolons for the IF. Commented Jun 5, 2015 at 17:02
  • Does inserting the formula directly (without macro) in the cell (of course with single ") works? Commented Jun 5, 2015 at 17:27
  • Hello, yes it works just fine without VBA. Already replaced with comas just have error 400 still :/ Commented Jun 5, 2015 at 18:01
  • Apologies. It works now. Thanks Commented Jun 5, 2015 at 18:04

1 Answer 1

1

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,

Sign up to request clarification or add additional context in comments.

2 Comments

Nice catch! Good eye.
Yeah, i realized that after some time, need new glasses! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.