title: Using variable in excel RC reference
body: <p>I am new to VBA/macro coding.  Trying to insert a variable in RC reference and it is not working.  I am not sure where I am making a mistake, any guidance is appreciated.</p>
  
  <pre><code>Dim var1 As Integer
  Dim var2 As Integer
  var1 = 1  'this changes dynamically in my actual program
  var2 = 2  'this changes dynamically in my actual program
  Range("A2").Select
  'following doesn't work
  ActiveCell.FormulaR1C1 = "=RC[var1]/RC[var2]"
  'following works
  ActiveCell.FormulaR1C1 = "=RC[1]/RC[2]"
  </code></pre>