title: vba error: object variable or with block variable not set
body: <p>I'm getting a "object variable or with block variable not set" error message when running the following code. It is in Access and refers to an Excel spreadsheet. What is wrong with the code?</p>
  
  <pre><code>wsTest.Range("A11").Activate    
  
  Do Until IsEmpty(ActiveCell)
      intX = intX + wsTest.Cells(ActiveCell.Row, "L") 'error occurs on this line
      intY = intY + wsTest.Cells(ActiveCell.Row, "I")
      ActiveCell.Offset(1, 0).Select ' Step down 1 row to the next cell.
  Loop
  </code></pre>
  
  <p>The first time the code is run, there is no error, only the second time. Closing and reopening Access "fixes" the problem. How can that be related to this code?</p>