问题描述
我对Excel VBA Formula功能有问题。我想要我的VBA子在单元格中生成以下公式:
= VLOOKUP(C5; data!J6:K611; 2 ; TRUE)
因此,我使用了以下VBA行:
Sheets(test)。Cells(1,1).Formula == VLOOKUP(C5; data!J6:K611; 2; TRUE)
这会导致错误:运行时错误1004:应用程序定义或对象定义的错误 / p>
如果我使用以下语句,然后手动添加公式前面的=,功能很好:
$ b $单元格(1,1).Value =VLOOKUP(C5; data!J6:K611; 2; TRUE)
我做错了什么?
我认为分隔符的转换发生在电子表格中而不是VBA中,您需要,
而不是;
。
请尝试:
表格(测试)细胞(1,1)== VLOOKUP(C5,data!J6:K611,2,1)
I have a problem with the Excel VBA Formula function. I want my VBA sub to generate the following formula in a cell:
=VLOOKUP(C5;data!J6:K611;2;TRUE)
Therefor, I used the following VBA line:
Sheets("test").Cells(1, 1).Formula = "=VLOOKUP(C5;data!J6:K611;2;TRUE)"
This results in an error: "Run-time error 1004: Application-defined or object-defined error"
If I use the following statement and afterwards manually add the "=" in front of the formula, the functions works well:
Sheets("test").Cells(1, 1).Value = "VLOOKUP(C5;data!J6:K611;2;TRUE)"
What am I doing wrong?
I think the conversion of delimiters takes place in the spreadsheet rather than in VBA - where you require ,
rather than ;
.
Please try:
Sheets("test").Cells(1, 1) = "=VLOOKUP(C5,data!J6:K611,2,1)"
这篇关于Excel VBA“公式”功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!