title: 'Run-time error 13' for a dynamic range with variables in VBA. Data type mismatch
body: <p>I am receiving a 'runtime error 13' for a line that is supposed to select a dynamic range from a worksheet in a opened workbook. I commented the line in the program.</p>
  
  <p>From research, I found that the 13 error is caused by a mismatch in data, so I tried changing my "v1, v2, v3..." variables to integers(they were <code>Dim As Long</code>).This had no effect.</p>
  
  <p>I specify a workbook and worksheet for each cell and range because I was receiving a '1004 error' before, &amp; the answer from another thread was to qualify the <code>ranges()</code> &amp; <code>cells()</code>.</p>
  
  <p>What is causing this error? Could there be an issue with the workbook and worksheet datatypes? Any help is appreciated. Thanks!</p>
  
  <pre><code>Sub FillPartNumRev()
  Dim ws As Worksheet, wb As Workbook
  Dim v1 As Range, v2 As Range, v3 As Range
  Dim r1 As Long, r2 As Long, r3 As Long, r4 As Long, r5 As Long
  Dim c1 As Long, c2 As Long, c3 As Long, c4 As Long, c5 As Long
  For x = 1 To 5000
  
  Set wb = Workbooks.Open(Filename:="IPIC_DATA.xlsx")
  
  r1 = 7: c1 = 0
  r2 = 7: c2 = 1
  r3 = 7: c3 = 2
  r4 = 7: c4 = 0
  r5 = 7: c5 = 1
  
  
  Set v1 = wb.Worksheets("Sheet1").Range(wb.Worksheets("Sheet1").Cells(r1, c1), wb.Worksheets("Sheet1").Cells(r2, c2))
  'run-time error 13
  Set v2 = wb.Worksheets("Sheet1").Range(wb.Worksheets("Sheet1").Cells(r3, c3))
  Set v3 = wb.Worksheets("Sheet1").Range(wb.Worksheets("Sheet1").Cells(r1, c1))
  Set v4 = wb.Worksheets("Sheet1").Range(wb.Worksheets("Sheet1").Cells(r4, c4), wb.Worksheets("Sheet1").Cells(r5, c5))
  
      If v4 &lt;&gt; "" &amp; v2 = "" Then
          v1.Copy v4
  
      ElseIf v4 = "" Then
          r1 = r1 + 7
          r2 = r2 + 7
  
      End If
  
  r4 = r4 + 1
  c4 = c4 + 1
  r5 = r5 + 1
  c5 = c5 + 1
  r3 = r3 + 1
  c3 = c3 + 1
  
  
  Next x
  
  
  End Sub
  </code></pre>