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

excel, vba

Solution

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.

Problem

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

Original source