title: Use an input variable inside a formula in macro
body: <p>I want to use a user input inside a formula as follows:</p>
  
  <pre><code>Sub example()
  
  Dim StockDays As Integer
  StockDays = InputBox(Prompt:="How many days?")
  
  Range("AG2").FormulaR1C1 = "=ROUNDUP(RC[-6]*" &amp; StockDays &amp; "/90, 0)"
  Range("AG2").Select
  Selection.AutoFill Destination:=Range(Cells(2, 33), Cells(1500, 33))
  
  End Sub
  </code></pre>
  
  <p>When run, the above code throws an error at the ROUNDUP line. </p>
  
  <blockquote>
    <p>Run-time error 1004.<br>
    Application-defined or object-defined error.</p>
  </blockquote>
  
  <p>I think the problem is related to the variable <code>StockDays</code>.</p>
  
  <p>How can I arrange the code so that I can make it work?</p>