title: Copy-Paste Efficiency and an Array of Worksheets in VBA
body: <p>I have the following code for pasting a certain range of cells in an array of worksheets - not all of them:</p>
  
  <pre><code>dim ws as Worksheet
  dim DecisionWorksheets
  dim myPassword as String
  dim copyrange
  dim wf as WorksheetFunction
  
  Set wf = Application.WorksheetFunction
  Set DecisionWorksheets = Sheets(Array("ADMIN", "LM", "CA", "FM", "GD"))
  For Each ws In DecisionWorksheets
      ws.Unprotect myPassword
      ws.Cells.ClearContents
  Next ws
  
  rownum = wf.Max(Range("B:B"))
  copyrange = Worksheets("Data").Range(Cells(4, 2), Cells(rownum + 3, 6)).Copy
  
  For Each ws In DecisionWorksheets
      ws.Range("B7").PasteSpecial xlPasteValues
  Next ws
  
  For Each ws In DecisionWorksheets
      ws.Protect myPassword
  Next ws
  </code></pre>
  
  <p>Each of the worksheets in an array above is password protected and if I put "ws.Unprotect myPassword" inside my second loop, the cut-copy mode is disabled. Because of this, I created a separate "for each" loop, which would first go through an array of worksheets to unprotect them (1st loop) and then to protect them back again (3rd loop). </p>
  
  <p>My question is about the efficiency of my code. Namely, I am just wondering whether there is any way I could unite these three loops into a single one.
  Any other suggestions would also be very appreciated!</p>