Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many ways to do this, and some are more efficient than others. My solution may not be the most efficient, but hopefully it will be easy for you to understand so that you can learn.</p> <p>It's very difficult to understand what you're attempting to do in activity three, so I wasn't able to provide a solution to that step. Use my code as a template for step three and if you run into issues, feel free to leave a comment.</p> <p>Notice that I don't use <code>.Activate</code>, <code>.Select</code>, or <code>.Copy</code> in this code. <code>.Activate</code> and <code>.Select</code> are huge efficiency killers, and they make it easier for your code to "break," so avoid using them when possible. <code>.Copy</code> isn't necessary when working with values or formulas and will also slow your code down. </p> <p><strong>Untested</strong></p> <pre><code>Sub testLoopPaste() Dim i As Long Dim ii As Long Dim i3 as Long Dim LastRow As Long Dim wb As Workbook Dim sht1 As Worksheet Dim sht2 As Worksheet Set wb = ThisWorkbook Set sht1 = wb.Sheets("Sheet1") Set sht2 = wb.Sheets("Sheet2") 'Find the last row (in column A) with data. LastRow = sht1.Range("A:A").Find("*", searchdirection:=xlPrevious).Row ii = 2 'This is the beginning of the loop For i = 3 To LastRow 'First activity sht2.Range("A" &amp; ii) = sht1.Range("F" &amp; i).Value sht2.Range("B" &amp; ii) = sht1.Range("D" &amp; i).Value sht2.Range("C" &amp; ii) = sht1.Range("A" &amp; i).Value sht2.Range("D" &amp; ii) = sht1.Range("H" &amp; i).Value ii = ii + 1 'Second activity sht2.Range("A" &amp; ii) = sht1.Range("F" &amp; i).Value sht2.Range("B" &amp; ii) = sht1.Range("D" &amp; i).Value sht2.Range("C" &amp; ii) = sht1.Range("A" &amp; i).Value sht2.Range("D" &amp; ii) = sht1.Range("I" &amp; i).Value ii = ii + 1 'Third activity For i3 = 1 To sht1.Range("K" &amp; I) sht2.Range("A" &amp; ii) = sht1.Range("F" &amp; i).Value sht2.Range("B" &amp; ii) = sht1.Range("D" &amp; i).Value sht2.Range("C" &amp; ii) = sht1.Range("A" &amp; i).Value ii = ii + 1 Next i3 Next i End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload