0

I am tying to replicate an excel formula IF(A2>300,"PASS","FAIL") using Range.Formula in VBA, but it is not working as required.

I am trying to call variables into the formula itself as shown below but it is retuing "end of statement" error. Somebody please help! Thanks

col_label = "A"
Range("B1").Formula = "=IF(" & col_label & 2" > 300, ""PASS"", ""FAIL"")"
2

1 Answer 1

1

Everything after col_label should be in quotes (double-quoted where necessary):

col_label = "A"
Range("B1").Formula = "=IF(" & col_label & "2 > 300, ""PASS"", ""FAIL"")"

enter image description here

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

1 Comment

Thank you - OP is referred to screen shot.

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.