title: VBA - Run Time Error 1004 'Application Defined or Object Defined Error'
body: <p>I have an Excel document that copies a template sheet into a new sheet on the first time it runs. Any more sheets that follow this template are appended to the newly created sheet.</p>
  
  <p>I'm getting the error in the title in this section of code:</p>
  
  <pre><code>If Worksheets("User Configuration").Cells(9, 15).Value = 1 Then
    Worksheets("Cable Cards Template").Range("A1:J33").Copy
  
    With Worksheets("Cable Cards")
    **.Range(Cells(RangeStartRow, RangeStartColumn), Cells(RangeEndRow, RangeEndColumn)).PasteSpecial xlValues**
      .Range(Cells(RangeStartRow, RangeStartColumn), Cells(RangeEndRow, RangeEndColumn)).PasteSpecial xlFormats
    End With
  
    Worksheets("Cable Cards Template").Shapes("Picture 1").Copy
    Worksheets("Cable Cards").Paste Cells(RangeStartRow, RangeStartColumn)
  
    Call Sheets.FormatCableCardRows      
  End If
  </code></pre>
  
  <p>Basically if the <code>If</code> statement is true (the cell = 1), then a range on a particular sheet should be copied and pasted into the new sheet at the range given using <code>PasteSpecial</code> for values and formatting. Following that, the "newly created" sheet should have an image copied into the top left cell of the template and then a subroutine is called to format the rows of the new sheet.</p>
  
  <p>I'm getting the error at the first <code>.Range</code> call after the <code>With Worksheets("Cable Cards")</code> statement. I've tried not using the <code>With</code> statement, copying values directly instead of paste-special etc. The weird thing is that this will run on the first go, when the new sheet is created via:</p>
  
  <pre><code>If (RangeStartRow = 1) Then
    Worksheets.Add().Name = "Cable Cards" ' Create new sheet with given name only on first cable card
    Columns(1).ColumnWidth = 9.43
    Columns(6).ColumnWidth = 11
    Columns(10).ColumnWidth = 9
    Call FormatForA5Printing("Cable Cards", 71)
  End If
  </code></pre>
  
  <p>but on the 2nd go, it fails entirely, with the <code>Run Time Error 1004 'Application Defined or Object Defined Error'</code>. I'd appreciate any help.</p>