Forum Discussion

Peter Sunden's avatar
Peter Sunden
Copper Contributor
May 29, 2018

Comma versus dot causes problems and I can't be alone or?

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

 

 

2 Replies

    • Peter Sunden's avatar
      Peter Sunden
      Copper Contributor

      Thanks Logaraj

       

      Using Single today and not Decimal. Have tried with Double with no result...

       

      Br

      Peter

Resources