title: VBA to cut, delete and move a row to another worksheet based on cell value using command button
body: <p>I have been working on a vba which will automatically move an entire row from the Mailing Log worksheet to the Completed Log worksheet if the values "Complete" or "Closed Incomplete" are entered into Column H using a command button in the header of Column H.</p>
  
  <p>The command button is working, but for some strange reason when it pastes the row into the completed log, instead of pasting it onto the next available line, it pastes it right at the bottom of the sheet in row "1048542". also I have only managed to get it working for the value 'Complete' and not yet for Closed Incomplete.</p>
  
  <p>Can someone please help? </p>
  
  <p>I have attached an example of my spreadsheets and my current VBA code Is as below:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
      Application.ScreenUpdating = False
          lastrow = Worksheets("Mailing LOG").UsedRange.Rows.Count
              lastrow2 = Worksheets("Completed Log").UsedRange.Rows.Count
                  If lastrow2 = 1 Then lastrow2 = 0
                      For r = lastrow To 2 Step -1
                          If Range("H" &amp; r).Value = "Complete" Then
                              Rows(r).Cut Destination:=Worksheets("Completed Log").Range("A" &amp; lastrow2 + 1)
              lastrow2 = lastrow2 + 1
              Else:
          End If
      Next r
  Application.ScreenUpdating = True
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/t2i7h.jpg" rel="nofollow noreferrer">Spreadsheet</a></p>