title: Why is Excel VBA giving me an error for a dynamic Range?
body: <p>I am trying to create a budget using a Match function, but I can't even get to that point because the dynamic Range I am trying to create is returning the error: "Application-defined or object-defined error".</p>
  
  <p>The range in question is <strong>rng</strong></p>
  
  <pre><code>Sub Material()
  
  Dim wSheet As Worksheet
  Dim x, dwIndex, offSet, count, upperLeft, bottomRight, r, wall As Integer
  Dim rng As Range
  
  x = 0
  
  For Each wSheet In Worksheets
      If wSheet.Name = "Drywall Pricing" Then
          dwIndex = wSheet.Index - 1
      End If
  Next wSheet
  
  For i = 1 To dwIndex
      If Sheets(i).Range("K1").Value &gt; 0 Then
          count = 9
          offSet = 41
          r = 27
          For wall = 1 To count
              offSet = (offSet * wall) - (offSet * 1)
              upperLeft = (r + 16) + offSet
              bottomRight = (r + 27) + offSet
              rng = Sheets(i).Range(Cells(upperLeft, 0), Cells(bottomRight, 1))
          Next wall
      End If
  Next i
  
  End Sub
  </code></pre>
  
  <p>Does anyone have any clue the variable <strong>rng</strong> is not valid? Any help would be just freaking great because this is getting ridiculous.</p>
  
  <p>Thanks in advance!</p>