title: "Application.Calculation = xlCalculationManual" statement causing run-time error 1004 in VBA Copy-Paste procedure
body: <p>I have VBA code that copies the first row and pastes the values to multiple rows.  The below code runs fine and pastes the rows as expected:</p>
  
  <pre><code>Sub Macro1()
    Dim i As Long
  
    Application.Calculation = xlCalculationManual
    Range("A1:M1").Select
    Selection.Copy
  
    For i = 1 To 50
      Range("A" &amp; i).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Next i
  End Sub
  </code></pre>
  
  <p>However, if I move <code>Application.Calculation = xlCalculationManual</code> down two lines as below, then the code throws a 1004 run-time error:  </p>
  
  <pre><code>Sub Macro1()
    Dim i As Long    
  
    Range("A1:M1").Select
    Selection.Copy
    Application.Calculation = xlCalculationManual
    For i = 1 To 50
      Range("A" &amp; i).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Next i
  End Sub
  </code></pre>
  
  <p>I've searched for information on the VBA language reference site here: <a href="http://msdn.microsoft.com/en-us/library/office/jj692818(v=office.15).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/office/jj692818(v=office.15).aspx</a> and the Excel developer reference site here: <a href="http://msdn.microsoft.com/en-us/library/office/ff194068(v=office.15).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/office/ff194068(v=office.15).aspx</a>.</p>
  
  <p>Further, I've verified this error using both Excel 2010 running on Windows 7 and 2013 running on Windows 8.1.</p>
  
  <p>Can someone help me understand why the location of <code>Application.Calculation = xlManualCalculation</code> would affect how the code runs?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I ran some additional tests to check if focus is lost or the clipboard is cleared.  First to see if focus is lost I recorded a Macro that copied the first row with ctrl + x, then I changed the calculation mode of the workbook, then I hit ctrl + x again without re-selecting the cells.  This is the resultant Macro:    </p>
  
  <pre><code>Sub MacroFocusTest()
      Range("A1:M1").Select
      Selection.Copy
      Application.CutCopyMode = False 'Macro recording entered this.
      Application.Calculation = xlManual
      Selection.Cut 'Range("A1:M1") is cut on the worksheet suggesting focus was not lost.
  End Sub
  </code></pre>
  
  <p>Next, I entered a variable into my original Macro1 to capture the Application.CutCopyMode at various stages of execution.  Follows is the resultant Macro:</p>
  
  <pre><code>Sub Macro1()
    Dim i As Long
    Dim bCCMode as Boolean    
  
    bCCMode = Application.CutCopyMode ' False
    Range("A1:M1").Select
    Selection.Copy
    bCCMode = Application.CutCopyMode ' True
    Application.EnableEvents = False ' Included because I mention in comments no error is thrown using this
    bCCMode = Application.CutCopyMode ' True
    Application.Calculation = xlCalculationManual
    bCCMode = Application.CutCopyMode ' False
    For i = 1 To 50
      Range("A" &amp; i).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Next i
  End Sub  
  </code></pre>
  
  <p>Based on the results of these two tests I believe that Application.Calculation = xlCalculationManual does not cause the range to lose focus, but does clear the clipboard.</p>