title: Out of Range error Copying UsedRange - Why did this break?
body: <p>(I know the code is messy - I'll refactor when it works)</p>
  <p>This code chucks up an 'Out of Range' error. <strong>It worked for days</strong>, and then suddenly stopped working and I can't figure out why.</p>
  <p>The desired functionality is:</p>
  <ol>
  <li>File dialog and open Excel file.</li>
  <li>Open the workbook</li>
  <li>Copy data in first sheet to clipboard</li>
  <li>Paste into A1 on pre-existing sheet in ThisWorkbook</li>
  <li>Close workbook</li>
  </ol>
  <p>Debugging suggests it's OpenBook.Sheets(1).UsedRange.Copy which is failing.</p>
  <p>I think I must have knocked something while editing at the bottom of the Sub?</p>
  <p>Thanks in advance :)</p>
  <pre><code>Sub Get_Data_From_File()
      
      Dim FileToOpen As Variant
      Dim OpenBook As Workbook
      
      'Stops screen flicker as focus changes
      Application.ScreenUpdating = False
      
      'Opens file dialogue and saves filename to FileToOpen
      FileToOpen = Application.GetOpenFilename(Title:=&quot;Choose the data you want to analyse.&quot;, FileFilter:=&quot;Excel Files (*.xls*),*xls*&quot;)
  
      'If a file is chosen, do this...
      If FileToOpen &lt;&gt; False Then
          'Ensure sheet is empty before pasting new values
          ThisWorkbook.Worksheets(&quot;Data&quot;).Cells.Clear
          
          Set OpenBook = Application.Workbooks.Open(FileToOpen)
          
          
          'THIS IS THE OFFENDING LINE
          OpenBook.Sheets(1).UsedRange.Copy
          
  
          'Pastes into the A1 cell
          ThisWorkbook.Worksheets(&quot;Data&quot;).Range(&quot;A1&quot;).PasteSpecial xlPasteValues
          If ThisWorkbook.Worksheets(&quot;Data&quot;).Cells(1, 1) &lt;&gt; &quot;Organisation and Cost Centre&quot; Then
              'Deletes the first two rows of the report which are file info only
              ThisWorkbook.Worksheets(&quot;Data&quot;).Rows(&quot;1:2&quot;).Delete
          End If
          'Change focus back to the Import Data sheet
          ThisWorkbook.Worksheets(&quot;Import Data&quot;).Activate
          'Close the source file
          OpenBook.Close SaveChanges:=False
          
      'Turn updating back on
      Application.ScreenUpdating = True
  
      End If
  
  End Sub
  </code></pre>