1

I would like to insert a function looking like this, using VBA:

=IF(ISERROR(VLOOKUP(B12,AASD!A:B,2,0)),"Check #",VLOOKUP(B12,AASD!A:B,2,0))

Code from VBA:

Sheets("Sheet1").Range("C12").Formula = "=IF(ISERROR(VLOOKUP(B12,AASD!A:B,2,0)),"Check AA#",VLOOKUP(B12,AASD!A:B,2,0))"

Issue is the "" quotes for inserting the string in the IF formula messes up the "" quotes in VBA.

Is there a clever work around for this?

2 Answers 2

4

Just double them up

Sheets("Sheet1").Range("C12").Formula = "=IF(ISERROR(VLOOKUP(B12,AASD!A:B,2,0)),""Check AA#"",VLOOKUP(B12,AASD!A:B,2,0))"

You can also use Chr(34) in place of a single set of quotes.

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

Comments

3

Additionally, that formula can be cut in half with IFERROR.

Sheets("Sheet1").Range("C12").Formula = _
   "=IFERROR(VLOOKUP(B12, AASD!A:B, 2, 0), ""Check AA#"")"

Comments

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.