title: Excel VBA- copy and insert row based on cell value
body: <p>I'm trying to accomplish this:</p>
  
  <p>column G      ========>  new    column G</p>
  
  <pre><code>2                            1
  
                               2
  
  2                            1
  
                               2
  
  1                            1
  
  1                            1
  
  2                            1
  
                               2
  </code></pre>
  
  <p>I've looked at many different questions to answer this but I believe my code is incorrect because I want to copy the entire row when initially G = 2 and insert it directly beneath, instead of the usual copy it to another sheet in excel.</p>
  
  <pre><code>Sub duplicate()
  Dim LastRow As Long
  Dim i As Integer
  For i = 2 To LastRow
  If Range("G" &amp; i).Value = "2" Then
      Range(Cells(Target.Row, "G"), Cells(Target.Row, "G")).Copy
      Range(Cells(Target.Row, "G"), Cells(Target.Row, "G")).EntireRow.Insert    Shift:=xlDown
  End If
  Next i
  End Sub
  </code></pre>
  
  <p>Thank you so much to any and all help!!</p>
  
  <p><a href="https://stackoverflow.com/questions/25395454/excel-vba-automation-copy-row-x-number-of-times-based-on-cell-value">Excel VBA automation - copy row &quot;x&quot; number of times based on cell value</a></p>