I am trying to add a formula to a cell. The macro is adding quotations around the cell range, which causes the cell to return the #name error.
This is the code in the macro
Cells(1, 4).FormulaR1C1 = "=VLOOKUP(RC[-2],Contracts!A7:D30,3,FALSE)"
This is what the code returns in Excel after executing the macro.
=VLOOKUP(B4,Contracts!'A7':'D30',3,FALSE)
Note that #name error disappears and the formula works, after I remove the quotations around the cell A7 and D30.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…