Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

excel

vba

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"

like image 877
ftkg Avatar asked Jan 20 '26 04:01

ftkg


1 Answers

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.

like image 127
Voitcus Avatar answered Jan 22 '26 22:01

Voitcus