title: Paste N Times Based on Column Value Isn't Working
body: <p>Thanks to a <a href="https://stackoverflow.com/questions/23665824/copy-paste-n-times-based-on-other-cell-values">previous post and some excellent direction</a> I was able to create successfully working code for my needs. However, the table/data has changed a bit and I have not yet reached my ultimate goal of iterating the paste function based on another cell's value. I have seen <a href="https://stackoverflow.com/questions/9099103/excel-2007-vba-copy-rows-x-times-based-on-text-filter">this post on SO</a> but it has not helped me. I found other resources on <a href="http://www.excel-easy.com/vba/loop.html" rel="nofollow noreferrer">using loops in Excel VBA</a> and created the very simple <code>Do While</code> code you see below.</p>
  
  <p>My problem: I cannot get the code to stop looping when it reaches the value from Column F. It finds the first available case and outputs the correct information endlessly without stopping at <em>n</em> value and moving on.</p>
  
  <p>Here is a look at the data table:</p>
  
  <pre><code>     A    B   C        D     E    F
   R1 Name Num Status   #Orig #Act #Rem
   R2 ABC  032 Complete 22    0    11
   R3 LMN  035 In Prog  25    21   4
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>Sub Copy_Pending_Status()
  
  Dim srcrange As Range
  Dim wb As Workbook
  Dim ws1 As Worksheet, ws2 As Worksheet
  Dim i As Integer
  
  Set wb = ActiveWorkbook
  Set ws1 = wb.Worksheets("SIS Agregate")
  Set ws2 = wb.Worksheets("Center Detail")
  Set srcrange = ws2.Range("C2:C61")
  
  For Each Row In srcrange.Cells
      Select Case Row.Value
          Case "In Progress"
              Do While i &lt;= Row.Offset(0, 3).Value
                  Set LastCell = ws1.Cells(ws1.Rows.Count, "C").End(xlUp).Offset(1)
                  LastCell.Offset(0, 0).Value = Row.Offset(0, -2).Value
                  LastCell.Offset(0, 12).Value = Row.Offset(0, -1).Value
                  LastCell.Offset(0, 4).Value = "Not Yet Scanned"
              Loop
  
          Case "Complete"
              Do While i &lt;= Row.Offset(0, 3).Value
                  Set LastCell = ws1.Cells(ws1.Rows.Count, "C").End(xlUp).Offset(1)
                  LastCell.Offset(0, 0).Value = Row.Offset(0, -2).Value
                  LastCell.Offset(0, 12).Value = Row.Offset(0, -1).Value
                  LastCell.Offset(0, 4).Value = "Purged"
              Loop
      End Select
  Next Row
  
  End Sub
  </code></pre>
  
  <p>I have tried setting the <code>Do While i &lt;= Row.Offset(0, 3).Value</code> to <code>(0,3)</code> <code>(0,4)</code> and <code>(0,6)</code> as I am not sure if it is counting the number of columns from "A" as one, "C" as one, or "C" as zero and offset is three (to the right). </p>
  
  <p>I want to note that eliminating the <code>Do While</code> and <code>Loop</code> lines of code from each case make this function correctly, but only once per row, per case - as opposed to however many times Column F indicates.</p>
  
  <p>Have I oversimplified this and am missing some obvious key information? What change do I need to make to get this little loop to function correctly?</p>