title: VBA Copy/Paste from one Sheet to All Others
body: <p>I am trying to copy one cell (D1) of sheet1 to a cell (D1) of all the workbook's other sheets (I am looping through files here and the number of worksheet varies). </p>
  
  <p>When running the code below, the line "ActiveSheet.Paste" gives me the following error: "Run-time error '10004': Paste method of Worksheet class failed".</p>
  
  <p>Here is the problematic piece of code:</p>
  
  <pre><code>'copy MSA code to sheets!=1
  Sub MSAallSheets(wb As Workbook)
      With wb
      Range("D1").Copy
          For Each ws In wb.Worksheets
              If ws.Name &lt;&gt; "Page 1" Then
              ws.Activate
              ws.Range("D1").Select
              ActiveSheet.Paste
              End If
          Next
      End With
  End Sub
  </code></pre>
  
  <p>In case it might be necessary, here is how I defined my loop through files:</p>
  
  <pre><code>Dim Filename, Pathname As String
  Dim wb As Workbook
  Pathname = "C:\Users\julia.anderson\Documents\HMDA\test\"
  Filename = Dir(Pathname &amp; "*.xlsx")
  Do While Filename &lt;&gt; ""
  Set wb = Workbooks.Open(Pathname &amp; Filename)
  DoWork wb
  Delete wb
  MSAallSheets wb
  wb.Close SaveChanges:=True
  Filename = Dir()
  Loop
  End Sub
  </code></pre>
  
  <p>Suggestions would be most welcome!</p>
  
  <p>Thank you.</p>