VBA Add Formula To Cell with Named Region from another closed WorkBook (Run-time error '1004')

放肆的年华 提交于 2020-01-25 06:48:10

问题


I need Create new workbook (wbook) and fill data from current - it's not a problem. I need add some data in wbook from another file (third). I try do with VLOOKUP.

=VLOOKUP(RC[-2];'C:\Users\xxx\Documents\RH.xlsx'!RHr;2)

correct work in cell

wBook.Sheets(1).Cells(7, 9).FormulaR1C1 = "=VLOOKUP(RC[-2];'C:\Users\xxx\Documents\RH.xlsx'!RHr;2)"

return Run-time error '1004'


回答1:


Found the issue, despite using the semicolon ; as your list separators in your formula (as per your country settings) vba only takes commas , and converts them to ; within the formula.

wbook.Sheets(1).Cells(7, 9).FormulaR1C1 = "=VLOOKUP(RC[-2],'C:\Users\xxx\Documents\RH.xlsx'!RHr,2)"


来源:https://stackoverflow.com/questions/58374349/vba-add-formula-to-cell-with-named-region-from-another-closed-workbook-run-time

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