title: Excel VBA - Paste a variable's value into a cell
body: <p>I have a <code>For</code> loop which will find a cell with a certain value in it (e.g. the word "Item"). Once it finds this cell, I want to paste a value into the row below it, in column I. </p>
  
  <p>For example, if the <code>For</code> loop finds "Item" in cell A1, I want to paste the value of a variable into cell I2.</p>
  
  <p>I'd like to be able to do this with both a <code>Long</code> variable and a <code>String</code> variable.</p>
  
  <p>Right now I'm trying something like:</p>
  
  <pre><code>Cells(i.Offset(1, 0), 9).Value = myLongVariable
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Cells(i.Offset(1, 0), 9).Text = myStringVariable
  </code></pre>
  
  <p>and other variations, but I keep getting an overflow error at this line.</p>
  
  <p>I've tried this: <code>Range("I" &amp; i.Offset(1, 0)).Value = myLongVariable</code> and slight variations, but I get an error that says <code>Run-time error 1004: Method Range of object _Worksheet failed</code></p>
  
  <p>Or <code>workBook.Sheets("Sheet1").Range("I" &amp; i.Offset(1, 0)).Value = myLongVariable</code> but that gives <code>Run-time error 1004: Application-defined or object-defined error</code>. Not sure what that refers to since I've defined <code>workBook</code> and <code>i</code> and <code>myLongVariable</code>.</p>
  
  <p>As a slightly different approach, I've tried pasting the variable data into the next blank cell of the row, which happens to be the cell in column I. Here's the code I used for that: <code>'i.Offset(1, 0).End(xlToRight).Offset(0, 1).Value = myLongVariable</code>. It works great, except in this scenario: cells A1:C1 are blank, D1:H1 have values. It should then paste the value into I1, but instead it thinks D1 is the end and posts it there. Any ideas on that?</p>
  
  <p>Thanks!</p>