在单元格中插入值或公式时,Excel VBA运行时错误1004 [英] Excel VBA Run-time error 1004 when inserting or value formula into cell
问题描述
当它尝试将公式插入单元格时出现运行时1004错误
I got the run-time 1004 error when It try to insert a formula into a cell
Range("B64").Value = "=INDEX(AK7:AK123;G74;1)"
//I also tried
Range("B64").Formula = "=INDEX(AK7:AK123;G74;1)"
//And
Range("B64").FormulaR1C1 = "=INDEX(AK7:AK123;G74;1)"
但这给出了错误.如果我尝试插入数字或常规字符串(例如"test"
),则可以正常工作,但不能正常工作.我是VBA的新手,我想知道为什么会出现问题,因为以前的语言永远都不会.
But this gives the error. If I try inserting a number or a regular string like "test"
it does work, but like this it doesn't. Im new to VBA and im wondering why this would give a problem since it would never in languages im used to.
推荐答案
在VBA中插入公式要求您使用EN-US标准,例如,
Inserting a formula with VBA requires that you use EN-US standards like,
Range("B64").Formula = "=INDEX(AK7:AK123, G74, 1)"
...或使用区域公式属性,如
... or use the regional formula attribute like,
Range("B64").FormulaLocal = "=INDEX(AK7:AK123; G74; 1)"
您可能还必须将 INDEX 更改为相应的区域.如果您的系统的区域设置未对列表分隔符使用逗号的EN-US标准,则必须使用后者.
You may have to also change INDEX to the regional equivalent. The latter is necessary when you have a system with regional settings that do not use the EN-US standard of a comma for a list separator.
请参见 Range.FormulaLocal属性(Excel )以获取更多信息.
see Range.FormulaLocal Property (Excel) for more information.
这篇关于在单元格中插入值或公式时,Excel VBA运行时错误1004的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!