title: Double variable in cell formula. What am I doing wrong here? Range("A2").Formula = "=A1+" & i
body: <p>Tried googling that, but no luck.</p>
  
  <p>Anyway, let's say I calculate some value of type double somewhere inside my code. Then I need to use this value in a cell formula. For whatever reason my approach does not seem to work, giving 1004.</p>
  
  <pre><code>Dim i As Double
  i = 0.5
  
  Range("A1").Value2 = 1
  Range("A2").Formula = "=A1+" &amp; i
  </code></pre>
  
  <p>What am I doing wrong here and why does it not work? It does work if you change to an integer value</p>
  
  <pre><code>Dim i As Double
  i = 2
  </code></pre>
  
  <p>Btw, the code below executes as expected</p>
  
  <pre><code>Dim i As Double
  i = 0.5
  
  Range("A2").Formula = i
  </code></pre>
  
  <p>Whereas if you change the last line to</p>
  
  <pre><code>Range("A2").Formula = "=" &amp; i
  </code></pre>
  
  <p>It returns 1004.</p>
  
  <p>Any help appreciated. Thank you!</p>