问题
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