title: Copy and Paste row by index number in Excel Macro
body: <p>I'm trying to copy an entire row by index number and paste it to another row with a different index number when a certain condition is met (I know the issue is not with the conditional logic). I'm thinking of something like this:</p>
  
  <pre><code>Sub Makro1()
  
  Dim i As Integer
  
  With ActiveSheet
      'for looping
      totalRows = .Cells(.Rows.Count, "A").End(xlUp).Row
  
      'index of last row even after rows have been added
      lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
  
      'data starts at row #3
      For i = 3 To totalRows
          If .Cells(i, 19).Value &gt; 0 Then
              Number = .Cells(i, 19).Value
              Do While Number &gt; 0
                  lastRow = lasRow + 1
                  'Next line doesnt do anything
                  .Rows(lastRow) = .Rows(i).Value
                  Number = Number - 1
              Loop
          End If
      Next i
  End With
  End Sub
  </code></pre>
  
  <p>The logic works like its supposed to but no lines are pasted. I've gone step by step and am certain the problem is not with the logic.</p>