title: Excel VBA incrementing variable in for loop
body: <p>I'm still a new learner of VBA programming, and I've come across an issue that I can't seem to find a solution to.  I am trying to create a workbook to handle recipes.  I am calling a user form used to add a recipe in a macro with several text box inputs (~96 of them).  When I've input all ingredients, quantity, units and press the OK button, I want it to write what's in the user form to the worksheet.  All text boxes are named ending with a number in ascending order (e.g. .txtIngredient1, .txtIngredient2, ...).  Is it possible to use a for loop to copy the Me.txtIngredientX.Value to a range on a sheet?</p>
  
  <p>A snippet of my current code:</p>
  
  <pre><code>Sheets("Recipes").Range("B" &amp; addatrow + 0) = Me.txtIngredient1.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 1) = Me.txtIngredient2.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 2) = Me.txtIngredient3.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 3) = Me.txtIngredient4.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 4) = Me.txtIngredient5.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 5) = Me.txtIngredient6.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 6) = Me.txtIngredient7.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 7) = Me.txtIngredient8.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 8) = Me.txtIngredient9.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 9) = Me.txtIngredient10.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 10) = Me.txtIngredient11.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 11) = Me.txtIngredient12.Value
  Sheets("Recipes").Range("B" &amp; addatrow + 12) = Me.txtIngredient13.Value
  </code></pre>
  
  <p>I have tried the only thing I know to do which is something like this:</p>
  
  <pre><code>for i = 1 to 32
      Sheets("Recipes").Range("B" &amp; addatrow - 1 + i) = me.txtIngredient &amp; i.value
  </code></pre>
  
  <p>which does not work.  Note: addatrow is a variable in the macro that dictates where the next recipe should be inserted.</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <p>Thanks!</p>