title: Excel 2007 VBA Range Variable References Cells Outside Assigned Range
body: <p>I've searched everywhere but haven't been able to figure out why a range variable is able to reference cells outside the assigned range.</p>
  
  <p>For example, if I write the code below:</p>
  
  <pre><code> Dim Rate as Range
   Set Rate = Range("A1:A5") 
  
   For Each Cell In Rate
        Debug.Print Cell.Value
   Next Cell
  
   Range("H6").Value = Rate(6).Value
   Range("H7").Value = Rate(7).Value
  </code></pre>
  
  <p>The above routine will only print out the 5 values in "A1:A5" -- BUT the last 2 statements cause the values in "A6" and "A7" to get stored in "H6" and "H7".  </p>
  
  <p>Since the variable "Rate" has only been assigned to "A1:A5", why is it able to reference other cells in column A (i.e., "A6" &amp; "A7")?</p>
  
  <p>Am I doing something wrong?  Any insight would be greatly appreciated!</p>