title: "Run-time error '1004': We couldn't paste this data because it took too long. Try reducing the size of the selection."
body: <p>This error is happening when the application is trying to a paste formula into an entire column. The code which is trying to paste the formula has been working for a few months and it seems to be consistently throwing the error on a particular remote computer.</p>
  <p>I copied the file on my device and tried running it locally. It throwed this error only the first two times, but after that, it seems to be working fine.</p>
  <p>I tried searching everywhere but I could not find this exact error elsewhere. All the other questions I found were related to using Select which I do not use. The exact error message I am getting reads:</p>
  <blockquote>
  <p>&quot;Run-time error '1004':  We couldn't paste this data because it took
  too long. Try reducing the size of the selection.  If you're copying
  from a remote computer, your network performance may be the cause.&quot;</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/9ciig.png" rel="nofollow noreferrer">Here's a screenshot of the error</a></p>
  <p>Below is the function where the error is happening and the line causing the error is indicated:</p>
  <pre><code>Public Function AutofillFormula()
  
  'declaring variables
  Dim shParts As Worksheet
  Dim ShapesRange As range
  Dim last_Row As Long
  
  'assigning sheet to sheet variable
  Set shParts = ActiveWorkbook.Sheets(&quot;Parts&quot;)
  Set tableParts = getTableFromSheet(worksheets(&quot;Parts&quot;))
  colShapes = Find_Column(&quot;Shapes&quot;, &quot;Parts&quot;, 1) ' This is a custom function which returns the letter of the column in a sheet
  
  Application.ScreenUpdating = False
  
  'Apply the formula to the row number 2 of the Shapes column in Parts sheet
  shParts.range(colShapes &amp; &quot;2&quot;).Formula = &quot;=INDEX(Sheet2!AA:AA,MATCH([@[Part Alpha]],Sheet2!A:A,0))&quot;
  
  'identify last filled cell of column A in Parts sheet
  last_Row = ActiveWorkbook.Sheets(&quot;Parts&quot;).Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row
  
  'create dynamic range
  Set ShapesRange = shParts.range(colShapes  &amp; &quot;2:&quot; &amp; colShapes &amp; last_Row)
  
  'Copy the formula
  shParts.range(colShapes &amp; &quot;2&quot;).Copy
  
  'Paste the copied formula to the dynamic range
  ShapesRange.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone ' **Line causing the error**
  
  Application.ScreenUpdating = True
  End Function
  </code></pre>
  <p>The number of rows where the formula is getting pasted is 15920. I ran this file with triple the number of rows on different devices and I am not getting this error.</p>
  <p>From the error message, it could be related to the network performance on this particular remote computer, but I don't see why I would get it on my local computer a couple of times. Any help with the cause of this error and potential fixes is much appreciated.</p>