title: How to copy then paste formulas from one workbook to another with VBA
body: <p>I have an existing VBA code that copies an Excel worksheet from my source workbook (<code>Sourcewb</code>) into a new destination workbook (<code>Destwb</code>) but pastes values only. I need a specific range (<code>D31:E38</code>) in the <code>Destwb</code> to include the formulas from the source workbook.  I found this code:</p>
  
  <pre><code>Range("A1:I1105").Copy Sheets("Sheet2").Range("B2")
  </code></pre>
  
  <p>On this site (another question) that seems related but don't know how to modify it to work in my application. I have added a comment line " 'Insert total formulas in Calc sheet" for where I think the additional code would go.  Here is my existing code:</p>
  
  <pre><code>Set Sourcewb = ActiveWorkbook
  
  'Copy the sheet to a new workbook
  Sheets("Calculation").Copy
  Set Destwb = ActiveWorkbook
  
  'Determine the Excel version and file extension/format
  With Destwb
      If Val(Application.Version) &lt; 12 Then
          'You use Excel 97-2003
          FileExtStr = ".xls": FileFormatNum = -4143
      Else
          'You use Excel 2007-2013
              FileExtStr = ".xlsx": FileFormatNum = 51
          End If
  End With
  
  'Change all cells in the worksheet to values if you want
  With Destwb.Sheets(1).UsedRange
      Application.CutCopyMode = False
      ActiveSheet.Unprotect
          .Cells.Copy
          .Cells.PasteSpecial xlPasteValues
          .Cells(1).Select
  End With
  Application.CutCopyMode = False
  
  'Insert total formulas in Calc sheet
  
  'Save the new workbook and close it
  TempFilePath = Sheets("Calculation").Range("L4").Value
  TempFileName = Range("L3").Value
  
  With Destwb
      .SaveAs TempFilePath &amp; "\" &amp; TempFileName &amp; FileExtStr, FileFormat:=FileFormatNum
      .Close SaveChanges:=True
  End With
  
  MsgBox "You can find the new file in " &amp; TempFilePath
  </code></pre>