Forum Discussion
Michael63
Mar 24, 2020Copper Contributor
VBA Runtime Error 1004 while assigning formula to a cell
I have created a small macro to apply a currency conversion with a fixed factor on selected cells. Sub ApplyUSD_ConversionRate()
'
' Devides through USD_ConversionRate on selected cells
'
...
JKPieterse
Mar 24, 2020Silver Contributor
In this case you could use cel.FormulaLocal instead of cel.Formula. That will ensure Excel does not take the comma in your decimal number to be a thousand separator (VBA speaks American)
Michael63
Mar 24, 2020Copper Contributor
Thanks, JKPieterse , for your suggestion.
I could actually resolve the issue by using .Formula instead of .Value:
cel.Formula = "=" & cel.Formula & "/USD_ConversionRate"