ftkg
ftkg

Reputation: 1772

VBA Runtime error 1004 on Cells(..).Formula

I can't make this simple command work:

Cells(l, 7).Formula = "=" & var1 & " * " & var2 & " * " & var3 & " / 252"

I can paste the inspected formula string value in Excel and it works as expected.

Cells(l,7) is a proper reference, as I can inspect its value.

Inspected formula on debug: "=86710597,9409 * 0,02 * 0,35 / 252"

Upvotes: 3

Views: 3299

Answers (1)

Voitcus
Voitcus

Reputation: 4446

The problem is when a variable is represented as string it will have the system's decimal point. In your case it is a comma so you need to convert it to dot, for example using replace() function.

Upvotes: 4

Related Questions