May 29 2018
11:35 AM
- last edited on
Jul 31 2018
08:17 AM
by
TechCommunityAP
May 29 2018
11:35 AM
- last edited on
Jul 31 2018
08:17 AM
by
TechCommunityAP
Hi, new in this forum and lives in Sweden (guess that one is a lead on the problem, Sweden I mean).
Writing a macro (as newbie) and stumbled into a problem working with constants containing decimals (exchange rates) in values.
Key parts of macro:
Dim sCurr As Single
sCurr = 7.1
ActiveCell.Offset(0, 8).FormulaR1C1 = "=RC[-3]*" & sCurr
Will bring on error 1004
If setting sCurr to 7 then it works like a charm
If trying to use the comma in the value then not allowed to do that.
sCurr will write correct value directly in a cell e.g. 7,1
The workaround is to have an intermediate step actually writing it into a cell and use absolute reference to that cell (B1). Then it works
ActiveCell.Offset(0, 8).FormulaR1C1 = "=RC[-3]*R1C2"
What am I missing? I like to have the formula as a result and not only value for audit purpose. It is supposed to be installed in several computers and I don't fancy to play around with local settings per country and stuff.
Thankful for all help I can get, spent hours doing the correct syntax in the formula over and over again without noticing the real problem
Peter
May 30 2018 03:41 AM
May 30 2018 10:27 AM
Thanks Logaraj
Using Single today and not Decimal. Have tried with Double with no result...
Br
Peter