VBA 将公式添加到另一个关闭的工作簿中具有命名区域的单元格(运行时错误“1004") [英] VBA Add Formula To Cell with Named Region from another closed WorkBook (Run-time error '1004')

查看:38
本文介绍了VBA 将公式添加到另一个关闭的工作簿中具有命名区域的单元格(运行时错误“1004")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建新的工作簿 (wbook) 并从当前填充数据 - 这不是问题.我需要从另一个文件(第三个)在 wbook 中添加一些数据.我尝试使用 VLOOKUP.

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)

在单元格中正确工作

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

返回运行时错误1004"

return Run-time error '1004'

推荐答案

发现问题,尽管使用分号 ; 作为公式中的列表分隔符(根据您的国家/地区设置)vba 只需要逗号 , 并将它们转换为 ; 在公式中.

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)"

这篇关于VBA 将公式添加到另一个关闭的工作簿中具有命名区域的单元格(运行时错误“1004")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆