title: Macros to copy and paste in loop
body: <p>For many of you this might be simple. I need to copy and paste data from 2 specific columns to a new spread sheet; but the macros need to stop when it reaches the end of data or when a cell is blank.</p>
  
  <p>So far the code looks like this:</p>
  
  <pre><code>Workbooks.Add
  ActiveCell.FormulaR1C1 = _
      "='[Muhanad_Reset_import-TEMPLATE.xlsx]Reset_import-Raw Data'!R1C1"
  Range("A1").Select
  ActiveCell.FormulaR1C1 = _
      "='[Muhanad_Reset_import-TEMPLATE.xlsx]Reset_import-Raw Data'!RC1"
  Range("B1").Select
  ActiveCell.FormulaR1C1 = _
      "='[Muhanad_Reset_import-TEMPLATE.xlsx]Reset_import-Raw Data'!R1C3"
  Range("B1").Select
  ActiveCell.FormulaR1C1 = _
      "='[Muhanad_Reset_import-TEMPLATE.xlsx]Reset_import-Raw Data'!RC3"
  Range("A1:B1").Select
  Selection.Copy
  Range("A2:A101").Select
  ActiveSheet.Paste
  Range("A1").Select
  Windows("Muhanad_Reset_import-TEMPLATE.xlsx").Activate
  </code></pre>
  
  <p>I know the code for copy and paste code does not work for a good result. </p>