Excel VBA Run-time error 1004 when inserting or value formula into cell

前端 未结 1 960
臣服心动
臣服心动 2020-12-04 02:47

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\").F         


        
相关标签:
1条回答
  • 2020-12-04 03:02

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

    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.

    see Range.FormulaLocal Property (Excel) for more information.

    0 讨论(0)
提交回复
热议问题