Excel macro formula adding quotes in formula causing vlookup to not work

南笙酒味 提交于 2019-11-27 16:30:55

You cannot mix RC and A1 style references in the same formula. Pick one and stick to it.

"=VLOOKUP(RC[-2],Contracts!R7C1:R30C4,3,FALSE)"

will work

The RC[-2] seems to be the problem. When I replaced that with a normal cell reference the macro didn't put quotes around the A7 and D30.

I believe the problem is caused by mixing RC notation (FormulaR1C1) and A1. Have you tried:

Cells(1, 4).FormulaR1C1 = "=VLOOKUP(RC[-2],""Contracts!A7:D30"",3,FALSE)"

? That should work.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!