title: Updated the vba code and still it gives me a subscript out of range error
body: <p>This code still gives me an out of subscript error</p>
  
  <pre><code>Sub importData2()
  
    ChDir "C:\Users\Desktop\Java"
    Dim filenum(0 To 10) As Long
    filenum(0) = 052
    filenum(1) = 060
    filenum(2) = 064
    filenum(3) = 068
    filenum(4) = 070
    filenum(5) = 072
    filenum(6) = 074
    filenum(7) = 076
    filenum(8) = 178
    filenum(9) = 180
    filenum(10) = 182
  
    Dim sh1 As Worksheet
    Dim rng As Range
    Set rng = Range(Selection, ActiveCell.SpecialCells(xlLastCell))
    Dim wb As Workbook
    Set wb = Application.Workbooks("30_graphs_w_Macro.xlsm")
  
    Dim sh2 As Worksheet
    Dim rng2 As Range
    Set rng2 = Range("A69")
    Dim wb2 As Workbook
  
    For lngposition = LBound(filenum) To UBound(filenum)
      Set wb2 = Application.Workbooks.Open(filenum(lngposition) &amp; ".csv")
      wb2.Worksheets(filenum(lngposition)).rng.Copy wb.Worksheets(filenum(lngposition)).rng2.Paste
    Next lngposition
  
  my_handler:
    MsgBox "All done."
  End Sub
  </code></pre>
  
  <p>This still gives me an out of subscript error on the line: </p>
  
  <pre><code>Set wb2 = Application.Workbooks(filenum(lngposition) &amp; ".csv")
  </code></pre>
  
  <p>I avoided using .active and .select. .select.</p>