title: Excel VBA runtime error 1004
body: <p>I'm trying to write a macro to paste special formulas but keep getting a runtime error 1004 "PasteSpecial method of Range class failed".</p>
  
  <p>This macro comes directly from using the "Record Macro" provided by Excel.</p>
  
  <pre><code>Sub paste_formulas()
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
           SkipBlanks:=False, Transpose:=False
  End Sub
  </code></pre>
  
  <p>Here is the sequence of events:</p>
  
  <ol>
  <li>Manually select a range of cells in CSV file A and copy (CTRL+C).</li>
  <li>Switch to the XLS file B and select the cell were I want the copied data pasted.</li>
  <li>Press Macros and run personal.xlsm!paste_formulas</li>
  </ol>
  
  <p>That's when I get the error. Why does this work manually when I copy/paste-special formulas, but fail in the macro?</p>
  
  <p>Note: I need this to work in the above sequence regardless of the selected range that I copy (will vary from time to time), and regardless of the location I paste formulas to (will also vary from time to time). In other words, hardcoding a fixed range for copy and/or paste won't work for me.</p>
  
  <p>Thanks in advance for any help understanding why my code isn't working or providing a work-around.</p>